Categories

Debian – Installer docker sous Debian 8 Jessie

Configurer l’accès au repository : /etc/apt/source.list

#—————————————————————————————–
# Security
deb http://security.debian.org/ jessie/updates main contrib non-free
deb-src http://security.debian.org/ jessie/updates main contrib non-free

# France mirror
deb http://ftp.fr.debian.org/debian/ jessie main contrib non-free
deb-src http://ftp.fr.debian.org/debian/ jessie main contrib non-free

#Docker
deb http://http.debian.net/debian jessie-backports main
#—————————————————————————————


Faire la mise à jour de Debian
#apt-get update && apt-get upgrade -y


Installation Docker

root@debian:~# apt-get install docker
root@debian:~# apt-get install docker.io

Vérification

root@debian:~# docker
Usage: docker [OPTIONS] COMMAND [arg…]A self-sufficient runtime for linux containers.Options:
–api-cors-header=                   Set CORS headers in the remote API
-b, –bridge=                        Attach containers to a network bridge
–bip=                               Specify network bridge

Lancer un container Ubuntu

root@debian:~# docker run -ti ubuntu /bin/bash
Unable to find image ‘ubuntu:latest’ locally
latest: Pulling from ubuntu
2a2723a6e328: Pull complete
fa1b78b7309e: Pull complete
0ce8ddcea421: Pull complete
c4cb212fd6fe: Pull complete
109d5efde28a: Pull complete
7f06d5cab2df: Pull complete
Digest: sha256:f649e49c1ed34607912626a152efbc23238678af1ac37859b6223ef28e711a3f
Status: Downloaded newer image for ubuntu:latest
root@1794152c37a0:/#root@1794152c37a0:/# ls
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@1794152c37a0:/# ps
PID TTY          TIME CMD
1 ?        00:00:00 bash
13 ?        00:00:00 ps
root@1794152c37a0:/#

Faire CTRL +P +Q pour quitter sans arrêter le container

root@1794152c37a0:/# root@debian:~#
root@debian:~# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS              PORTS               NAMES
1794152c37a0        ubuntu:latest       “/bin/bash”         About a minute ago   Up About a minute                       modest_perlman
root@debian:~#

root@debian:~# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
1794152c37a0        ubuntu:latest       “/bin/bash”         2 minutes ago       Up 2 minutes                            modest_perlman
root@debian:~# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
1794152c37a0        ubuntu:latest       “/bin/bash”         2 minutes ago       Up 2 minutes                            modest_perlman
root@debian:~# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
ubuntu              latest              7f06d5cab2df        5 days ago          130 MB
root@debian:~#

Reconnecter dans le container Ubuntu

root@debian:~# docker exec -ti modest_perlman /bin/bash
root@1794152c37a0:/# ls
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@1794152c37a0:/# ps
PID TTY          TIME CMD
14 ?        00:00:00 bash
27 ?        00:00:00 ps
root@1794152c37a0:/#

Lancer une commande d’exécution par le container

root@debian:~# docker exec -ti modest_perlman echo “test docker Ubuntu”
test docker Ubuntu
root@debian:~#

Arrêt du container

root@debian:~# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
1794152c37a0        ubuntu:latest       “/bin/bash”         5 minutes ago       Up 5 minutes                            modest_perlman
root@debian:~# docker stop 1794152c37a0
1794152c37a0
root@debian:~# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
root@debian:~#Supression du container

root@debian:~# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
1794152c37a0        ubuntu:latest       “/bin/bash”         6 minutes ago       Exited (0) 35 seconds ago                       modest_perlman
root@debian:~# docker rm 1794152c37a0
1794152c37a0
root@debian:~# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
root@debian:~#

Delete process docker
#docker rm $(docker ps -a -f status=exited -q)

Delete images docker
#docker rmi $(docker images -a -q)


 

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  

  

  

This site uses Akismet to reduce spam. Learn how your comment data is processed.