Docker Community: Installation

Comment installer docker

Docker Community: Installation

Premièrement, désinstaller toutes les composantes docker qui pourraient être installer.

En tant que root:

apt-get remove docker docker-engine docker.io containerd runc

Deuxièmement, installer les pré-requis

apt install ca-certificates curl gnupg lsb-release

Pour installer docker à partir du repo officiel, on doit ajouter la clé PGP.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Pour ajouter le repo stable on roule la commande suivante

echo
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Installation: Docker-engine

  1. Mettre à jour les repos
  2. Installer docker-ce docker-ce-cli et containerd.io
apt update && apt install docker-ce docker-ce-cli containerd.io

Vérifier que docker est installer correctement en roulant l'image hello-world

docker run hello-world

Si votre installation fonctionne, vous devriez voir ce message

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:2498fce14358aa50ead0cc6c19990fc6ff866ce72aeb5546e1d59caac3d0d60f
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:

The Docker client contacted the Docker daemon.

The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)

The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading

The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/get-started/

Rouler docker en tant qu'un usager non-root

Il est toujours préférable de rouler docker en tant qu'un usager non-root. Pour ce faire, créer un groupe qui s'appelle docker

groupadd docker

Ensuite, ajouter votre user au groupe docker

usermod -aG docker <user>

Maintenant, faire un logoff / login avec votre user et refaites un docker run hello-world pour vérifier que vous pouvez démarrer des containers avec votre user.


Configurer docker pour qu'il démarre suite à un reboot

Simplement rouler les commandes suivantes

systemctl enable docker.service
systemctl enable containerd.service