Différences
Ci-dessous, les différences entre deux révisions de la page.
| Prochaine révision | Révision précédente | ||
| elearning:workbooks:docker3:drf04 [2021/11/21 11:41] – created admin | elearning:workbooks:docker3:drf04 [2024/02/21 13:40] (Version actuelle) – admin | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| ~~PDF: | ~~PDF: | ||
| - | Version : **2021.01** | + | Version : **2024.01** |
| Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
| - | ======DOF605 - Stocker les Images | + | ======DOF605 - Docker |
| =====Contenu du Module===== | =====Contenu du Module===== | ||
| - | * **DOF605 - Stocker les Images | + | * **DOF605 - Docker |
| * Contenu du Module | * Contenu du Module | ||
| - | * LAB #1 - Installer un Registre Privé | + | * LAB #1 - Docker Compose |
| - | * 1.1 - Installer docker | + | * 1.1 - Installation |
| - | * 1.2 - Préparation | + | * 1.2 - Installer Wordpress avec Docker Compose |
| - | * 1.3 - Créer un Registre local, | + | * LAB #2 - Docker Machine |
| - | * 1.4 - Créer un Serveur | + | * 2.1 - Présentation |
| - | * Configurer le clone comme Registre Dédié | + | * 2.2 - Création de Machines Virtuelles Docker |
| - | * Configurer | + | * 2.3 - Lister les VM Docker |
| + | * 2.4 - Obtenir l' | ||
| + | * 2.5 - Se connecter à une VM Docker | ||
| + | * LAB #3 - Docker Swarm | ||
| + | * 3.1 - Présentation | ||
| + | * 3.2 - Initialiser Docker Swarm | ||
| + | * 3.3 - Le Statut Leader | ||
| + | * 3.4 - Rejoindre le Swarm | ||
| + | * 3.5 - Consulter les Informations | ||
| + | * 3.6 - Démarrer un Service | ||
| + | * 3.7 - Augmentation et Réduction du Service | ||
| + | * 3.8 - Consulter | ||
| + | * 3.9 - Haute Disponibilité | ||
| + | * 3.10 - Supprimer un Service | ||
| + | * 3.11 - Sauvegarder Docker Swarm | ||
| + | * 3.12 - Restaurer Docker Swarm | ||
| - | =====LAB #1 - Installer un Registre Privé===== | + | =====LAB #1 - Docker Compose===== |
| - | ====1.1 - Installer | + | Docker Compose est un utilitaire de compilation d' |
| - | Docker n' | + | Ce fichier, appelé par la commande **docker-compose build** commence avec un mot clef **image** ou **build** selon que l'image est récupérée sur un registre ou provient du répertoire cité dans le fichier. Le reste du fichier contient des instructions pour définir la compilation des images constituantes, |
| + | |||
| + | Une fois totalement construite, l'application peut ensuite être pilotée très simplement par l' | ||
| + | |||
| + | De cette façon | ||
| + | |||
| + | ====1.1 - Installation==== | ||
| + | |||
| + | Récupérez docker-compose avec **curl** | ||
| < | < | ||
| - | root@debian9:~# apt-get update | + | root@debian11:~# curl -L " |
| - | ... | + | % Total % Received % Xferd Average Speed |
| - | root@debian9: | + | Dload Upload |
| - | Reading package lists... Done | + | |
| - | Building dependency tree | + | 100 24.7M 100 24.7M 0 |
| - | Reading state information... Done | + | |
| - | ca-certificates is already the newest version. | + | |
| - | ca-certificates set to manually installed. | + | |
| - | gnupg2 is already the newest version. | + | |
| - | gnupg2 set to manually installed. | + | |
| - | The following extra packages will be installed: | + | |
| - | libcurl3 python3-dbus python3-software-properties unattended-upgrades | + | |
| - | Suggested packages: | + | |
| - | python-dbus-doc python3-dbus-dbg | + | |
| - | The following NEW packages will be installed: | + | |
| - | apt-transport-https curl libcurl3 python3-dbus python3-software-properties | + | |
| - | software-properties-common unattended-upgrades | + | |
| - | 0 upgraded, 7 newly installed, 0 to remove and 1 not upgraded. | + | |
| - | Need to get 960 kB of archives. | + | |
| - | After this operation, 2,344 kB of additional disk space will be used. | + | |
| - | Do you want to continue? [Y/n] | + | |
| </ | </ | ||
| - | Téléchargez | + | Vérifiez |
| < | < | ||
| - | root@debian9:~# curl -fsSL https:// | + | root@debian11:~# docker-compose |
| - | OK | + | Docker Compose version v2.0.1 |
| </ | </ | ||
| - | Vérifiez que l'ID de la clef est **9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88** : | + | Rendez |
| < | < | ||
| - | root@debian9:~# apt-key fingerprint 0EBFCD88 | + | root@debian11:~# chmod +x / |
| - | /etc/apt/trusted.gpg | + | |
| - | -------------------- | + | root@debian11: |
| - | pub 4096R/0EBFCD88 2017-02-22 | + | -rwxr-xr-x 1 root root 25907200 Dec 16 12:15 / |
| - | Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 | + | |
| - | uid Docker Release (CE deb) <docker@docker.com> | + | |
| - | sub | + | |
| - | ... | + | |
| </ | </ | ||
| - | Ajoutez le dépôt | + | Les options de la commande |
| < | < | ||
| - | root@debian9:~# add-apt-repository " | + | root@debian11:~# docker-compose |
| + | |||
| + | Usage: | ||
| + | |||
| + | Docker Compose | ||
| + | |||
| + | Options: | ||
| + | --ansi string | ||
| + | | ||
| + | | ||
| + | --compatibility | ||
| + | --env-file string | ||
| + | -f, --file stringArray | ||
| + | --profile stringArray | ||
| + | --project-directory string | ||
| + | | ||
| + | -p, --project-name string | ||
| + | |||
| + | Commands: | ||
| + | build Build or rebuild services | ||
| + | convert | ||
| + | cp Copy files/folders between a service container and the local filesystem | ||
| + | create | ||
| + | down Stop and remove containers, networks | ||
| + | events | ||
| + | exec Execute a command in a running container. | ||
| + | images | ||
| + | kill Force stop service containers. | ||
| + | logs View output from containers | ||
| + | ls List running compose projects | ||
| + | pause pause services | ||
| + | port Print the public port for a port binding. | ||
| + | ps List containers | ||
| + | pull Pull service images | ||
| + | push Push service images | ||
| + | restart | ||
| + | rm Removes stopped service containers | ||
| + | run Run a one-off command on a service. | ||
| + | start Start services | ||
| + | stop Stop services | ||
| + | top | ||
| + | unpause | ||
| + | up Create and start containers | ||
| + | |||
| + | Run ' | ||
| </ | </ | ||
| - | <WRAP center round important> | + | ====1.2 |
| - | **Important** | + | |
| - | </ | + | |
| - | Installez | + | Créez |
| < | < | ||
| - | root@debian9: | + | root@debian9: |
| - | ... | + | |
| - | root@debian9: | + | |
| - | Reading package lists... Done | + | |
| - | Building dependency tree | + | |
| - | Reading state information... Done | + | |
| - | The following extra packages will be installed: | + | |
| - | aufs-tools cgroupfs-mount git git-man libapparmor1 liberror-perl | + | |
| - | libnih-dbus1 libnih1 makedev mountall plymouth rsync | + | |
| - | Suggested packages: | + | |
| - | git-daemon-run git-daemon-sysvinit git-doc git-el git-email git-gui gitk | + | |
| - | gitweb git-arch git-cvs git-mediawiki git-svn plymouth-themes | + | |
| - | The following NEW packages will be installed: | + | |
| - | aufs-tools cgroupfs-mount docker-ce git git-man libapparmor1 liberror-perl | + | |
| - | libnih-dbus1 libnih1 makedev mountall plymouth rsync | + | |
| - | 0 upgraded, 13 newly installed, 0 to remove and 99 not upgraded. | + | |
| - | Need to get 26.5 MB of archives. | + | |
| - | After this operation, 123 MB of additional disk space will be used. | + | |
| - | Do you want to continue? [Y/n] | + | |
| </ | </ | ||
| - | Dernièrement, | + | Placez-vous dans le répertoire |
| < | < | ||
| - | root@debian9: | + | root@debian9: |
| - | Client: Docker Engine | + | root@debian9:~/ |
| - | Version: 19.03.4 | + | root@debian9:~/ |
| - | API version: | + | version: |
| - | Go version: | + | |
| - | Git commit: | + | services: |
| - | Built: Fri Oct 18 15:52:34 2019 | + | db: |
| - | OS/Arch: linux/amd64 | + | image: mysql:5.7 |
| - | Experimental: false | + | volumes: |
| - | + | - db_data:/var/ | |
| - | Server: Docker Engine - Community | + | |
| - | Engine: | + | |
| - | | + | |
| - | API version: 1.40 (minimum version 1.12) | + | |
| - | | + | |
| - | Git commit: 9013bf583a | + | |
| - | Built: Fri Oct 18 15:51:05 2019 | + | |
| - | | + | |
| - | | + | |
| - | containerd: | + | - db |
| - | | + | image: wordpress:latest |
| - | | + | ports: |
| - | runc: | + | - "8000:80" |
| - | | + | |
| - | | + | |
| - | docker-init: | + | |
| - | | + | |
| - | | + | |
| + | | ||
| + | volumes: | ||
| + | | ||
| </ | </ | ||
| - | <WRAP center round important> | + | Exécutez la commande docker-compose |
| - | **Important** | + | |
| - | </ | + | |
| - | Re-démarrez la machine virtuelle avant de poursuivre | + | < |
| + | root@debian11: | ||
| + | [+] Running 12/12 | ||
| + | ⠿ db Pulled | ||
| + | ⠿ 20e4dcae4c69 Pull complete | ||
| + | ⠿ 1c56c3d4ce74 Pull complete | ||
| + | ⠿ e9f03a1c24ce Pull complete | ||
| + | ⠿ 68c3898c2015 Pull complete | ||
| + | ⠿ 6b95a940e7b6 Pull complete | ||
| + | ⠿ 90986bb8de6e Pull complete | ||
| + | ⠿ ae71319cb779 Pull complete | ||
| + | ⠿ ffc89e9dfd88 Pull complete | ||
| + | ⠿ 43d05e938198 Pull complete | ||
| + | ⠿ 064b2d298fba Pull complete | ||
| + | ⠿ df9a4d85569b Pull complete | ||
| + | [+] Running 4/4 | ||
| + | ⠿ Network wordpress1_default | ||
| + | ⠿ Volume " | ||
| + | ⠿ Container wordpress1-db-1 | ||
| + | ⠿ Container wordpress1-wordpress-1 | ||
| + | </ | ||
| + | |||
| + | Vérifiez que le Wordpress fonctionne | ||
| < | < | ||
| - | root@debian9:~# shutdown | + | root@debian11:~/wordpress1# lynx --dump http:// |
| + | | ||
| + | | ||
| + | |||
| + | | ||
| + | |||
| + | root@debian11: | ||
| + | CONTAINER ID | ||
| + | 9475874569e1 | ||
| + | 5983cdf711ec | ||
| + | cf27f30654d2 | ||
| + | 33a264a36bdc | ||
| + | 81e6fcb9f692 | ||
| + | 5083545dcbf8 | ||
| + | 227554e3e4c1 | ||
| + | 63fec083f4d6 | ||
| + | db3732939266 | ||
| + | 57e92a8b25d7 | ||
| + | fc417b22a20d | ||
| + | cb2875ab1059 | ||
| + | 2126924504d8 | ||
| + | |||
| + | root@debian11: | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | |||
| + | root@debian11: | ||
| + | | ||
| + | | ||
| + | |||
| + | | ||
| </ | </ | ||
| - | ====1.2 - Préparation==== | + | <WRAP center round important 50%> |
| + | **Important** - La commande **docker-compose up** est une abréviation des commandes **docker-compose build && docker-compose run**. L' | ||
| + | </ | ||
| - | Vous devez vous connecter | + | =====LAB #2 - Docker Machine===== |
| + | |||
| + | ====2.1 - Présentation==== | ||
| + | |||
| + | Docker Machine est un outil qui vous permet d' | ||
| + | |||
| + | Le jeu de commandes de docker-machine permet de démarrer, surveiller, arrêter et re-démarrer un hôte géré, de mettre à jour le client/ | ||
| + | |||
| + | Pour installer docker-machine sur votre VM **debian11**, | ||
| < | < | ||
| - | trainee@traineeXX:~$ ssh -l trainee 10.0.2.60 | + | root@debian11:~/ |
| + | |||
| + | root@debian11: | ||
| + | % Total % Received % Xferd Average Speed | ||
| + | | ||
| + | 0 | ||
| + | 100 32.6M 100 32.6M 0 | ||
| </ | </ | ||
| - | ou : | + | ====2.2 - Création de Machines Virtuelles Docker===== |
| + | |||
| + | La création d'une machine se fait simplement en utilisant la commande **docker-machine** avec la sous-commande **create**. Cette sous-commande prend l' | ||
| + | |||
| + | ^ Fournisseur ^ driver ^ | ||
| + | | [[https:// | ||
| + | | [[https:// | ||
| + | | [[https:// | ||
| + | | [[https:// | ||
| + | | [[http:// | ||
| + | | [[https:// | ||
| + | | [[https:// | ||
| + | | [[https:// | ||
| + | | [[https:// | ||
| + | | [[https:// | ||
| + | | [[https:// | ||
| + | | [[https:// | ||
| + | | [[https:// | ||
| + | |||
| + | Commencez par installer Oracle VirtualBox: | ||
| < | < | ||
| - | trainee@traineeXX:~$ ssh -l trainee | + | root@debian11:~# apt install virtualbox-6.1 -y |
| + | Reading package lists... Done | ||
| + | Building dependency tree... Done | ||
| + | Reading state information... Done | ||
| + | The following packages were automatically installed and are no longer required: | ||
| + | libopengl0 linux-headers-5.10.0-15-amd64 linux-headers-5.10.0-15-common | ||
| + | Use 'apt autoremove' | ||
| + | Recommended packages: | ||
| + | linux-image | ||
| + | The following packages will be upgraded: | ||
| + | virtualbox-6.1 | ||
| + | 1 upgraded, 0 newly installed, 0 to remove and 16 not upgraded. | ||
| + | Need to get 95.8 MB of archives. | ||
| + | After this operation, 53.2 kB disk space will be freed. | ||
| + | Get:1 http:// | ||
| + | Fetched 95.8 MB in 3s (31.4 MB/s) | ||
| + | apt-listchanges: | ||
| + | Preconfiguring packages ... | ||
| + | (Reading database ... 166797 files and directories currently installed.) | ||
| + | Preparing to unpack .../ | ||
| + | Unpacking virtualbox-6.1 (6.1.48-159471~Debian~bullseye) over (6.1.46-158378~Debian~bullseye) ... | ||
| + | Setting up virtualbox-6.1 (6.1.48-159471~Debian~bullseye) ... | ||
| + | addgroup: The group `vboxusers' | ||
| + | Processing triggers for hicolor-icon-theme (0.17-2) ... | ||
| + | Processing triggers for shared-mime-info (2.0-1) ... | ||
| + | Processing triggers for mailcap (3.69) ... | ||
| + | Processing triggers for desktop-file-utils (0.26-1) ... | ||
| </ | </ | ||
| - | Passez en tant que **root** : | + | Créez le fichier |
| < | < | ||
| - | trainee@debian9:~$ su - | + | root@debian11:~# vi / |
| - | Mot de passe : fenestros | + | root@debian11:~# cat / |
| - | root@debian9:~# | + | * 10.0.0.0/8 192.168.0.0/ |
| </ | </ | ||
| - | Créez | + | Créez |
| < | < | ||
| - | root@debian9:~# mkdir ~/myDocker | + | root@debian11:~# docker-machine create --driver virtualbox manager1 |
| - | root@debian9:~# cd ~/myDocker | + | Running pre-create checks... |
| - | root@debian9:~/myDocker# | + | (manager1) Image cache directory does not exist, creating it at /root/ |
| + | (manager1) No default Boot2Docker ISO found locally, downloading the latest release... | ||
| + | (manager1) Latest release for github.com/ | ||
| + | (manager1) Downloading /root/ | ||
| + | (manager1) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100% | ||
| + | Creating machine... | ||
| + | (manager1) Copying /root/.docker/ | ||
| + | (manager1) Creating VirtualBox VM... | ||
| + | (manager1) Creating SSH key... | ||
| + | (manager1) Starting the VM... | ||
| + | (manager1) Check network to re-create if needed... | ||
| + | (manager1) Found a new host-only adapter: " | ||
| + | (manager1) Waiting for an IP... | ||
| + | Waiting for machine to be running, this may take a few minutes... | ||
| + | Detecting operating system of created instance... | ||
| + | Waiting for SSH to be available... | ||
| + | Detecting the provisioner... | ||
| + | Provisioning with boot2docker... | ||
| + | Copying certs to the local machine directory... | ||
| + | Copying certs to the remote machine... | ||
| + | Setting Docker configuration on the remote daemon... | ||
| + | Checking connection to Docker... | ||
| + | Docker is up and running! | ||
| + | To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env manager1 | ||
| </ | </ | ||
| - | Créez le fichier myEntrypoint.sh | + | Les options de la commande **docker-machine** sont : |
| < | < | ||
| - | root@debian9:~/myDocker# vi myEntrypoint.sh | + | root@debian11:~# docker-machine --help |
| - | root@debian9:~/myDocker# cat myEntrypoint.sh | + | Usage: docker-machine |
| - | # | + | |
| - | if [ -z " | + | |
| - | echo "La variable myVariable doit être renseignée" | + | |
| - | return 1 | + | |
| - | fi | + | |
| - | while true; | + | Create and manage machines running Docker. |
| - | do | + | |
| - | echo $1 \($(date +%H: | + | |
| - | sleep " | + | |
| - | done | + | |
| - | </ | + | |
| - | Testez ce script | + | Version: 0.16.2, build bd45ab13 |
| - | <code> | + | Author: |
| - | root@debian9:~/myDocker# myVariable=3 . ./myEntrypoint.sh salut | + | Docker Machine Contributors - <https://github.com/docker/machine> |
| - | salut (20: | + | |
| - | salut (20: | + | |
| - | salut (20: | + | |
| - | salut (20: | + | |
| - | salut (20: | + | |
| - | ^C | + | |
| - | root@debian9: | + | |
| - | </code> | + | |
| - | Rendez ce script exécutable | + | Options: |
| + | --debug, -D | ||
| + | --storage-path, | ||
| + | --tls-ca-cert | ||
| + | --tls-ca-key | ||
| + | --tls-client-cert | ||
| + | --tls-client-key | ||
| + | --github-api-token | ||
| + | --native-ssh | ||
| + | --bugsnag-api-token | ||
| + | --help, -h show help | ||
| + | --version, -v print the version | ||
| + | |||
| + | Commands: | ||
| + | active | ||
| + | config | ||
| + | create | ||
| + | env | ||
| + | inspect | ||
| + | ip Get the IP address of a machine | ||
| + | kill Kill a machine | ||
| + | ls List machines | ||
| + | provision | ||
| + | regenerate-certs | ||
| + | restart | ||
| + | rm Remove a machine | ||
| + | ssh Log into or run a command on a machine with SSH. | ||
| + | scp Copy files between machines | ||
| + | mount Mount or unmount a directory from a machine with SSHFS. | ||
| + | start Start a machine | ||
| + | status | ||
| + | stop Stop a machine | ||
| + | upgrade | ||
| + | url Get the URL of a machine | ||
| + | version | ||
| + | help Shows a list of commands or help for one command | ||
| + | |||
| + | Run ' | ||
| + | </ | ||
| + | |||
| + | Les options de la sous-commande **create** de la commande **docker-machine** sont : | ||
| < | < | ||
| - | root@debian9:~/myDocker# chmod u+x myEntrypoint.sh | + | root@debian11:~# docker-machine create --help |
| - | </ | + | Usage: docker-machine create [OPTIONS] [arg...] |
| - | Créez maintenant | + | Create a machine |
| + | |||
| + | Description: | ||
| + | Run ' | ||
| + | |||
| + | Options: | ||
| + | |||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | </ | ||
| + | |||
| + | Créez maintenant | ||
| < | < | ||
| - | root@debian9:~/myDocker# vi Dockerfile | + | root@debian11:~# docker-machine create --driver virtualbox worker1 |
| - | root@debian9:~/myDocker# cat Dockerfile | + | Running pre-create checks... |
| - | FROM centos: | + | Creating machine... |
| - | MAINTAINER i2tch " | + | (worker1) Copying /root/.docker/ |
| - | COPY myEntrypoint.sh /entrypoint.sh | + | (worker1) Creating VirtualBox VM... |
| - | ENV myVariable 3 | + | (worker1) Creating SSH key... |
| - | ENTRYPOINT ["/ | + | (worker1) Starting the VM... |
| - | CMD [" | + | (worker1) Check network to re-create if needed... |
| + | (worker1) Waiting for an IP... | ||
| + | Waiting for machine to be running, this may take a few minutes... | ||
| + | Detecting operating system of created instance... | ||
| + | Waiting for SSH to be available... | ||
| + | Detecting the provisioner... | ||
| + | Provisioning with boot2docker... | ||
| + | Copying certs to the local machine directory... | ||
| + | Copying certs to the remote machine... | ||
| + | Setting Docker configuration on the remote daemon... | ||
| + | Checking connection to Docker... | ||
| + | Docker is up and running! | ||
| + | To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env worker1 | ||
| </ | </ | ||
| - | |||
| - | Générez maintenant l' | ||
| < | < | ||
| - | root@debian9:~/myDocker# docker | + | root@debian11:~# docker-machine create |
| - | Sending build context to Docker daemon | + | ... |
| - | Step 1/6 : FROM centos: | + | root@debian11: |
| - | ---> 9f38484d220f | + | ... |
| - | Step 2/6 : MAINTAINER i2tch " | + | root@debian11:~# docker-machine create |
| - | ---> Running in 02c700ed04da | + | ... |
| - | Removing intermediate container 02c700ed04da | + | root@debian11:~# docker-machine create |
| - | | + | ... |
| - | Step 3/6 : COPY myEntrypoint.sh /entrypoint.sh | + | |
| - | ---> 7a3923372768 | + | |
| - | Step 4/6 : ENV myVariable 3 | + | |
| - | ---> Running in 3288bf6291ad | + | |
| - | Removing intermediate container 3288bf6291ad | + | |
| - | | + | |
| - | Step 5/6 : ENTRYPOINT ["/ | + | |
| - | ---> Running in 8dcba2c41520 | + | |
| - | Removing intermediate container 8dcba2c41520 | + | |
| - | | + | |
| - | Step 6/6 : CMD [" | + | |
| - | ---> Running in f891fbcfaad0 | + | |
| - | Removing intermediate container f891fbcfaad0 | + | |
| - | | + | |
| - | Successfully built 7925ba23abb2 | + | |
| - | Successfully tagged i2tch/ | + | |
| </ | </ | ||
| - | ====1.3 - Installer un Registre Local==== | + | ====2.3 - Lister les VM Docker==== |
| - | Pour installer un registre privé, il convient d'utiliser une image publique | + | Pour lister les VM Docker ainsi que leurs états, il convient d'utilise la sous-commande **ls** |
| < | < | ||
| - | root@debian9: | + | root@debian11:~# docker-machine ls |
| - | root@debian9:~# docker | + | NAME |
| - | Unable to find image ' | + | manager1 |
| - | 2.0: Pulling from library/ | + | worker1 |
| - | 4d2e9ae40c41: Pull complete | + | worker2 |
| - | a3ed95caeb02: Pull complete | + | worker3 |
| - | 7c8152785df5: Pull complete | + | worker4 |
| - | 8b04aafd7cd8: Pull complete | + | worker5 |
| - | c97c75d2d42e: Pull complete | + | |
| - | 4b3ef98bba76: Pull complete | + | |
| - | edee0288d356: Pull complete | + | |
| - | ea2a9399d365: Pull complete | + | |
| - | ddf532273b60: | + | |
| - | e9e91aa1843e: | + | |
| - | 6144b0ffbb4c: | + | |
| - | Digest: sha256: | + | |
| - | Status: Downloaded newer image for registry:2.0 | + | |
| - | c4c7cad999cdd77df78a21897bd11c4742a094c1c76a2134fbe4a4d2d92bff0e | + | |
| </ | </ | ||
| - | Utilisez maintenant **lynx** à partir | + | ====2.4 - Obtenir l' |
| + | |||
| + | Une autre façon | ||
| < | < | ||
| - | root@debian9:~# lynx --dump http://localhost:88/v2 | + | root@debian11:~# docker-machine ip manager1 |
| - | {}root@debian9:~# | + | 192.168.99.100 |
| + | root@debian11: | ||
| + | 192.168.99.101 | ||
| + | root@debian11:~# docker-machine ip worker2 | ||
| + | 192.168.99.102 | ||
| + | root@debian11:~# docker-machine ip worker3 | ||
| + | 192.168.99.103 | ||
| + | root@debian11:~# docker-machine ip worker4 | ||
| + | 192.168.99.104 | ||
| + | root@debian11: | ||
| + | 192.168.99.105 | ||
| </ | </ | ||
| - | <WRAP center round important> | + | ====2.5 |
| - | **Important** | + | |
| - | </ | + | |
| - | Renommez l'image **i2tch/ | + | Pour se connecter à une VM Docker, il convient d'utiliser la sous-commande |
| < | < | ||
| - | root@debian9:~# docker | + | root@debian11:~# docker-machine ssh manager1 |
| + | ( '>' | ||
| + | | ||
| + | (/-_--_-\) | ||
| + | |||
| + | docker@manager1: | ||
| + | logout | ||
| + | root@debian11: | ||
| </ | </ | ||
| - | <WRAP center round important> | + | <WRAP center round important |
| - | **Important** - Notez que le tag **i2tch/mydocker** cache le nom du registre par défaut qui est le registre public de Docker Hub. | + | **Important** - Notez que la distribution de la VM est **[[http:// |
| </ | </ | ||
| - | Envoyez votre image **localhost: | + | Installez maintenant le paquet |
| < | < | ||
| - | root@debian9:~# docker push localhost:88/mydocker | + | root@debian11:~# apt install mlocate -y |
| - | The push refers | + | Reading package lists... Done |
| - | 873a8ac77d4d: | + | Building dependency tree... Done |
| - | b362758f4793: | + | Reading state information... Done |
| - | latest: digest: sha256: | + | The following packages were automatically installed and are no longer required: |
| + | libopengl0 linux-headers-5.10.0-15-amd64 linux-headers-5.10.0-15-common | ||
| + | Use 'apt autoremove' | ||
| + | Suggested packages: | ||
| + | nocache | ||
| + | The following NEW packages will be installed: | ||
| + | mlocate | ||
| + | 0 upgraded, 1 newly installed, 0 to remove and 16 not upgraded. | ||
| + | Need to get 98.3 kB of archives. | ||
| + | After this operation, 517 kB of additional disk space will be used. | ||
| + | Get:1 http:// | ||
| + | Fetched 98.3 kB in 0s (1,985 kB/s) | ||
| + | Selecting previously unselected package mlocate. | ||
| + | (Reading database ... 166797 files and directories currently installed.) | ||
| + | Preparing to unpack .../ | ||
| + | Unpacking mlocate (0.26-5) ... | ||
| + | Setting up mlocate (0.26-5) ... | ||
| + | update-alternatives: using / | ||
| + | Adding group `mlocate' | ||
| + | Done. | ||
| + | Created symlink / | ||
| + | mlocate.service is a disabled or a static unit, not starting it. | ||
| + | Processing triggers for man-db (2.9.4-2) ... | ||
| </ | </ | ||
| - | Constatez maintenant la présence de l' | + | Ayant été créées par root, les VM Docker ainsi que leurs fichiers associés sont stockés |
| < | < | ||
| - | root@debian9:~# lynx --dump http://localhost: | + | root@debian11:~# updatedb |
| - | {" | + | |
| + | root@debian11:~# locate manager1 | ||
| + | /root/.docker/machine/machines/manager1 | ||
| + | /root/ | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| </ | </ | ||
| + | |||
| + | =====LAB #3 - Docker Swarm===== | ||
| + | |||
| + | ====3.1 - Présentation==== | ||
| + | |||
| + | Docker Swarm est un utilitaire qui permet de gérer un cluster pour déployer des conteneurs en permettant une imitation du comportement de docker sur une seule machine. | ||
| + | |||
| + | ====3.2 - Initialiser Docker Swarm==== | ||
| + | |||
| + | Pour initialiser Docker swarm, il convient d' | ||
| < | < | ||
| - | root@debian9:~# docker | + | root@debian11:~# docker-machine ssh manager1 |
| - | REPOSITORY | + | ( '>' |
| - | i2tch/mydocker | + | /) TC (\ Core is distributed with ABSOLUTELY NO WARRANTY. |
| - | localhost: | + | (/-_--_-\) |
| - | registry | + | |
| + | docker@manager1: | ||
| + | Swarm initialized: | ||
| + | |||
| + | To add a worker to this swarm, run the following command: | ||
| + | |||
| + | docker swarm join --token SWMTKN-1-25tbmsyx452cuhpiedymuc8n9llo9jbjcbza93npdo35q1aaff-9teuxcpe09xw7v7xz1tnwpw4g 192.168.99.100: | ||
| + | |||
| + | To add a manager to this swarm, run ' | ||
| </ | </ | ||
| - | ====1.4 - Créer | + | Notez que les ports suivants doivent être ouverts sur un nœud manager : 22/tcp, 2376/tcp, 2377/tcp, 7946/tcp, 7946/udp et 4789/udp. |
| - | Actuellement, | + | ====3.3 |
| - | Connectez-vous à la VM Debian_9_1 | + | Consultez le statut de la VM Docker manager1 |
| < | < | ||
| - | trainee@traineeXX:~$ ssh -l trainee 10.0.2.61 | + | docker@manager1:~$ docker node ls |
| + | ID HOSTNAME | ||
| + | y0war0lijmwhnexrfhfflulsd * | ||
| </ | </ | ||
| - | ou | + | A un instant t il ne peut y avoir q'un seul **Leader**. Il est possible de créer d' |
| + | |||
| + | Pour connaître le token nécessaire pour rejoindre swarm en tant que nœud de gestion, saisissez la commande suivante : | ||
| < | < | ||
| - | trainee@traineeXX:~$ ssh -l trainee 10.0.2.41 | + | docker@manager1:~$ docker swarm join-token manager |
| + | To add a manager to this swarm, run the following command: | ||
| + | |||
| + | docker swarm join --token SWMTKN-1-25tbmsyx452cuhpiedymuc8n9llo9jbjcbza93npdo35q1aaff-1teue04djnc4vu2eufzty59ys 192.168.99.100:2377 | ||
| </ | </ | ||
| - | En tant que root, modifiez | + | ====3.4 - Rejoindre |
| + | |||
| + | Rejoignez les 5 machines travailleurs à swarm en utilisant le token **worker** | ||
| < | < | ||
| - | trainee@debian91:~$ su - | + | docker@manager1:~$ exit |
| - | Mot de passe : fenestros | + | logout |
| - | root@debian91:~# nmcli general hostname myregistry.i2tch.loc | + | |
| - | root@debian91:~# hostname | + | root@debian11: |
| - | myregistry.i2tch.loc | + | ( '>' |
| + | /) TC (\ Core is distributed with ABSOLUTELY NO WARRANTY. | ||
| + | | ||
| + | |||
| + | docker@worker1:~$ docker swarm join --token SWMTKN-1-25tbmsyx452cuhpiedymuc8n9llo9jbjcbza93npdo35q1aaff-9teuxcpe09xw7v7xz1tnwpw4g 192.168.99.100: | ||
| + | This node joined a swarm as a worker. | ||
| + | |||
| + | docker@worker1: | ||
| + | logout | ||
| + | |||
| + | root@debian11:~# docker-machine ssh worker2 | ||
| + | ( '>' | ||
| + | /) TC (\ Core is distributed with ABSOLUTELY NO WARRANTY. | ||
| + | | ||
| + | |||
| + | docker@worker2: | ||
| + | This node joined a swarm as a worker. | ||
| + | |||
| + | docker@worker2: | ||
| + | logout | ||
| + | |||
| + | root@debian11:~# docker-machine ssh worker3 | ||
| + | ( '>' | ||
| + | /) TC (\ Core is distributed with ABSOLUTELY NO WARRANTY. | ||
| + | | ||
| + | |||
| + | docker@worker3: | ||
| + | This node joined a swarm as a worker. | ||
| + | |||
| + | docker@worker3: | ||
| + | logout | ||
| + | |||
| + | root@debian11: | ||
| + | ( '>' | ||
| + | /) TC (\ Core is distributed with ABSOLUTELY NO WARRANTY. | ||
| + | | ||
| + | |||
| + | docker@worker4: | ||
| + | This node joined a swarm as a worker. | ||
| + | |||
| + | docker@worker4: | ||
| + | logout | ||
| + | |||
| + | root@debian11: | ||
| + | ( '>' | ||
| + | /) TC (\ Core is distributed with ABSOLUTELY NO WARRANTY. | ||
| + | | ||
| + | |||
| + | docker@worker5: | ||
| + | This node joined a swarm as a worker. | ||
| + | |||
| + | docker@worker5: | ||
| + | logout | ||
| + | |||
| + | root@debian11: | ||
| </ | </ | ||
| - | Installez | + | Notez que les ports suivants doivent être ouverts sur un nœud worker : 22/tcp, 2376/tcp, 7946/tcp, 7946/udp et 4789/udp. |
| + | |||
| + | L' | ||
| < | < | ||
| - | root@debian91:~# apt-get update | + | root@debian11:~# docker-machine ssh manager1 |
| - | root@debian91: | + | ( '>' |
| - | root@debian91: | + | /) TC (\ Core is distributed with ABSOLUTELY NO WARRANTY. |
| - | root@debian91: | + | (/-_--_-\) www.tinycorelinux.net |
| - | root@debian91: | + | |
| - | root@debian91:~# apt-get install | + | docker@manager1:~$ docker |
| + | ID HOSTNAME | ||
| + | y0war0lijmwhnexrfhfflulsd * | ||
| + | v5ai62lmhfsdcauccqmjyu6qk | ||
| + | j4mr3d2ji30t7hu0trob5dpgz | ||
| + | pouo7nuvirq0qkuvvrp04a47h | ||
| + | mo0dd5ech6ifdgd8pa6cjz896 | ||
| + | 5am2vd39pybytu1nd3oooabtq | ||
| </ | </ | ||
| - | Pour Trainee10 | + | Notez que vous ne pouvez pas utiliser cette commande |
| < | < | ||
| - | root@debian91:~# vi /etc/hosts | + | docker@manager1:~$ exit |
| - | root@debian91:~# cat /etc/hosts | + | logout |
| - | 127.0.0.1 localhost | + | |
| - | 10.0.2.60 debian9.i2tch.loc debian9 | + | root@debian11:~# docker-machine ssh worker5 |
| - | 10.0.2.61 myregistry.i2tch.loc myregistry | + | ( '>' |
| - | 10.0.2.62 manager.i2tch.loc manager | + | /) TC (\ Core is distributed with ABSOLUTELY NO WARRANTY. |
| - | 10.0.2.63 worker1.i2tch.loc worker1 | + | (/ |
| - | 10.0.2.64 worker2.i2tch.loc worker2 | + | |
| + | docker@worker5: | ||
| + | Error response from daemon: This node is not a swarm manager. | ||
| + | |||
| + | docker@worker5: | ||
| + | logout | ||
| + | exit status 1 | ||
| - | # The following lines are desirable for IPv6 capable hosts | + | root@debian11: |
| - | ::1 | + | |
| - | ff02::1 ip6-allnodes | + | |
| - | ff02::2 ip6-allrouters | + | |
| </ | </ | ||
| - | Pour Trainee20 à Trainee29, éditez | + | ====3.5 - Consulter les Informations de Swarm==== |
| + | |||
| + | Il est possible de visualiser les informations concernant | ||
| < | < | ||
| - | root@debian91:~# vi /etc/hosts | + | root@debian11:~# docker-machine ssh manager1 |
| - | root@debian91: | + | ( '>' |
| - | 127.0.0.1 localhost | + | |
| - | 10.0.2.40 debian9.i2tch.loc debian9 | + | (/ |
| - | 10.0.2.41 myregistry.i2tch.loc | + | |
| - | 10.0.2.42 manager.i2tch.loc manager | + | docker@manager1: |
| - | 10.0.2.43 worker1.i2tch.loc worker1 | + | Client: |
| - | 10.0.2.44 worker2.i2tch.loc worker2 | + | Debug Mode: false |
| - | # The following lines are desirable for IPv6 capable hosts | + | Server: |
| - | ::1 | + | Containers: 0 |
| - | ff02::1 ip6-allnodes | + | Running: 0 |
| - | ff02::2 ip6-allrouters | + | Paused: 0 |
| + | Stopped: 0 | ||
| + | | ||
| + | | ||
| + | | ||
| + | Backing Filesystem: extfs | ||
| + | Supports d_type: true | ||
| + | Native Overlay Diff: true | ||
| + | | ||
| + | | ||
| + | | ||
| + | Volume: local | ||
| + | Network: bridge host ipvlan macvlan null overlay | ||
| + | Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog | ||
| + | Swarm: active | ||
| + | NodeID: y0war0lijmwhnexrfhfflulsd | ||
| + | Is Manager: true | ||
| + | ClusterID: w3mq6i01k4siboyqv3w3nbyu7 | ||
| + | Managers: 1 | ||
| + | Nodes: 6 | ||
| + | Default Address Pool: 10.0.0.0/ | ||
| + | SubnetSize: 24 | ||
| + | Data Path Port: 4789 | ||
| + | Orchestration: | ||
| + | Task History Retention Limit: 5 | ||
| + | Raft: | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | Dispatcher: | ||
| + | | ||
| + | CA Configuration: | ||
| + | | ||
| + | Force Rotate: 0 | ||
| + | Autolock Managers: false | ||
| + | Root Rotation In Progress: false | ||
| + | Node Address: 192.168.99.100 | ||
| + | Manager Addresses: | ||
| + | | ||
| + | | ||
| + | | ||
| + | Init Binary: docker-init | ||
| + | containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429 | ||
| + | runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd | ||
| + | init version: fec3683 | ||
| + | | ||
| + | seccomp | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | CPUs: 1 | ||
| + | Total Memory: 985.4MiB | ||
| + | Name: manager1 | ||
| + | ID: UIL3: | ||
| + | | ||
| + | Debug Mode: false | ||
| + | | ||
| + | | ||
| + | provider=virtualbox | ||
| + | | ||
| + | | ||
| + | 127.0.0.0/ | ||
| + | Live Restore Enabled: false | ||
| + | | ||
| </ | </ | ||
| - | Créez maintenant un certificat auto-signé avec **openssl** : | + | <WRAP center round important 50%> |
| + | **Important** | ||
| + | </ | ||
| + | |||
| + | ====3.6 - Démarrer un Service==== | ||
| + | |||
| + | Dans cet exemple, nous allons démarrer le service **nginx** avec les propriétés suivantes | ||
| + | |||
| + | * Mappage du port nginx sur le port 80 de la machine hôte, | ||
| + | * 5 instances du service, | ||
| + | * Un nom unique de **web**. | ||
| < | < | ||
| - | root@debian91:~# cd / && mkdir certs && openssl req -newkey rsa: | + | docker@manager1:~$ docker service create |
| - | Generating a 4096 bit RSA private key | + | oree977o1unlk5ndos0y44i2h |
| - | ............................................................++ | + | overall progress: 5 out of 5 tasks |
| - | .......................................................................................................................................++ | + | 1/5: running |
| - | writing new private key to 'certs/domain.key' | + | 2/5: running |
| - | ----- | + | 3/5: running |
| - | You are about to be asked to enter information that will be incorporated | + | 4/5: running |
| - | into your certificate request. | + | 5/5: running |
| - | What you are about to enter is what is called a Distinguished Name or a DN. | + | verify: Service converged |
| - | There are quite a few fields but you can leave some blank | + | |
| - | For some fields there will be a default value, | + | |
| - | If you enter ' | + | |
| - | ----- | + | |
| - | Country Name (2 letter code) [AU]:FR | + | |
| - | State or Province Name (full name) [Some-State]:VAR | + | |
| - | Locality Name (eg, city) []:Toulon | + | |
| - | Organization Name (eg, company) [Internet Widgits Pty Ltd]:I2TCH LTD | + | |
| - | Organizational Unit Name (eg, section) | + | |
| - | Common Name (e.g. server FQDN or YOUR name) []:myregistry | + | |
| - | Email Address | + | |
| - | root@registry:/# ls certs/ | + | |
| - | domain.crt | + | |
| </ | </ | ||
| - | Créez un conteneur en mode sécurisé avec TLS à partir de l'image registry | + | Pour consulter |
| < | < | ||
| - | root@registry:/# docker | + | docker@manager1:~$ docker |
| - | 943c01b67cf3f461270a55ac3d9df6622cc9d74e5f272e17153183ff29ee5932 | + | ID NAME MODE REPLICAS |
| - | root@debian9: | + | oree977o1unl |
| + | </code> | ||
| - | root@registry:/# docker ps -a | + | Ce service fonctionne dans des conteneurs Docker : |
| - | CONTAINER | + | |
| - | 943c01b67cf3 | + | < |
| + | docker@manager1:~$ docker | ||
| + | ID | ||
| + | son0vgc73drb | ||
| + | ojqyweuo65jw | ||
| + | mb40onnaxd0u | ||
| + | 4vwsho5x7i36 | ||
| + | sk9hr6j2u47c | ||
| </ | </ | ||
| - | Envoyez une copie du fichier | + | <WRAP center round important 50%> |
| + | **Important** - Notez qu'il n'y a pas de conteneur sur worker1. | ||
| + | </ | ||
| + | |||
| + | Pour constater | ||
| < | < | ||
| - | root@debian91:~# scp / | + | docker@manager1:~$ docker ps |
| - | The authenticity of host ' | + | CONTAINER ID IMAGE |
| - | ECDSA key fingerprint is 79:00: | + | 244fecd46312 |
| - | Are you sure you want to continue connecting (yes/no)? yes | + | |
| - | Warning: Permanently added '10.0.2.60' (ECDSA) to the list of known hosts. | + | |
| - | trainee@10.0.2.60' | + | |
| - | domain.crt | + | |
| </ | </ | ||
| - | ou : | + | Par contre la même commande exécutée sur **worker1** donne le résultat suivant |
| < | < | ||
| - | root@debian91:~# scp / | + | docker@manager1: |
| - | The authenticity of host ' | + | logout |
| - | ECDSA key fingerprint | + | |
| - | Are you sure you want to continue connecting | + | root@debian11:~# docker-machine ssh worker1 |
| - | Warning: Permanently added '10.0.2.40' | + | |
| - | trainee@10.0.2.40' | + | /) TC (\ |
| - | domain.crt | + | (/-_--_-\) www.tinycorelinux.net |
| + | |||
| + | docker@worker1:~$ docker ps | ||
| + | CONTAINER ID IMAGE | ||
| + | docker@worker1:~$ exit | ||
| + | logout | ||
| + | |||
| + | root@debian11: | ||
| </ | </ | ||
| - | ===Configurer | + | Connectez-vous sur chaque VM Docker pour constater que le service nginx fonctionne : |
| - | Sortez de la VM **debian91** et connectez-vous à la VM debian9 | + | < |
| + | root@debian11: | ||
| + | ( '>' | ||
| + | /) TC (\ Core is distributed with ABSOLUTELY NO WARRANTY. | ||
| + | | ||
| + | |||
| + | docker@manager1: | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | html { color-scheme: | ||
| + | body { width: 35em; margin: 0 auto; | ||
| + | font-family: | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | <p>If you see this page, the nginx web server is successfully installed and | ||
| + | working. Further configuration is required.</ | ||
| + | |||
| + | < | ||
| + | <a href=" | ||
| + | Commercial support is available at | ||
| + | <a href=" | ||
| + | |||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | docker@manager1: | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | html { color-scheme: | ||
| + | body { width: 35em; margin: 0 auto; | ||
| + | font-family: | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | <p>If you see this page, the nginx web server is successfully installed and | ||
| + | working. Further configuration is required.</ | ||
| + | |||
| + | < | ||
| + | <a href=" | ||
| + | Commercial support is available at | ||
| + | <a href=" | ||
| + | |||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | docker@manager1: | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | html { color-scheme: | ||
| + | body { width: 35em; margin: 0 auto; | ||
| + | font-family: | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | <p>If you see this page, the nginx web server is successfully installed and | ||
| + | working. Further configuration is required.</ | ||
| + | |||
| + | < | ||
| + | <a href=" | ||
| + | Commercial support is available at | ||
| + | <a href=" | ||
| + | |||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | docker@manager1: | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | html { color-scheme: | ||
| + | body { width: 35em; margin: 0 auto; | ||
| + | font-family: | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | <p>If you see this page, the nginx web server is successfully installed and | ||
| + | working. Further configuration is required.</ | ||
| + | |||
| + | < | ||
| + | <a href=" | ||
| + | Commercial support is available at | ||
| + | <a href=" | ||
| + | |||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | docker@manager1: | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | html { color-scheme: | ||
| + | body { width: 35em; margin: 0 auto; | ||
| + | font-family: | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | <p>If you see this page, the nginx web server is successfully installed and | ||
| + | working. Further configuration is required.</ | ||
| + | |||
| + | < | ||
| + | <a href=" | ||
| + | Commercial support is available at | ||
| + | <a href=" | ||
| + | |||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | docker@manager1: | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | html { color-scheme: | ||
| + | body { width: 35em; margin: 0 auto; | ||
| + | font-family: | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | <p>If you see this page, the nginx web server is successfully installed and | ||
| + | working. Further configuration is required.</ | ||
| + | |||
| + | < | ||
| + | <a href=" | ||
| + | Commercial support is available at | ||
| + | <a href=" | ||
| + | |||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 50%> | ||
| + | **Important** - Notez que le service est même disponible en consultant l' | ||
| + | </ | ||
| + | |||
| + | ====3.7 - Augmentation | ||
| + | |||
| + | Actuellement, | ||
| < | < | ||
| - | trainee@traineeXX:~$ ssh -l trainee 10.0.2.60 | + | docker@manager1:~$ docker service scale web=8 |
| + | web scaled to 8 | ||
| + | overall progress: 8 out of 8 tasks | ||
| + | 1/8: running | ||
| + | 2/8: running | ||
| + | 3/8: running | ||
| + | 4/8: running | ||
| + | 5/8: running | ||
| + | 6/8: running | ||
| + | 7/8: running | ||
| + | 8/8: running | ||
| + | verify: Service converged | ||
| </ | </ | ||
| - | ou | + | Notez que la commande **docker service ls** confirme le fait qu'il y a 8 replicas : |
| < | < | ||
| - | trainee@traineeXX:~$ ssh -l trainee 10.0.2.40 | + | docker@manager1:~$ docker service ls |
| + | ID NAME MODE REPLICAS | ||
| + | oree977o1unl | ||
| </ | </ | ||
| - | Passez en tant que **root** | + | Des trois replicas supplémentaires, |
| < | < | ||
| - | trainee@debian9:~$ su - | + | docker@manager1:~$ docker service ps web |
| - | Mot de passe : fenestros | + | ID NAME IMAGE |
| - | root@debian9:~# | + | son0vgc73drb |
| + | ojqyweuo65jw | ||
| + | mb40onnaxd0u | ||
| + | 4vwsho5x7i36 | ||
| + | sk9hr6j2u47c | ||
| + | pui4dnkepu27 | ||
| + | yj0kexdcuo5u | ||
| + | 93jtbxqj2dyz | ||
| </ | </ | ||
| - | Supprimez | + | ====3.8 - Consulter |
| + | |||
| + | Pour se renseigner sur le statut du nœud courant, il convient d' | ||
| < | < | ||
| - | root@debian9:~# docker | + | docker@manager1:~$ docker |
| - | CONTAINER | + | [ |
| - | c4c7cad999cd | + | { |
| - | 21b0490a93dd | + | "ID": " |
| + | " | ||
| + | " | ||
| + | | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | " | ||
| + | " | ||
| + | "Labels": | ||
| + | " | ||
| + | }, | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | ] | ||
| + | }, | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | }, | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | } | ||
| + | ] | ||
| + | </ | ||
| - | root@debian9: | + | Pour se renseigner sur le statut d'un autre nœud, il convient d' |
| - | registry | + | |
| - | root@debian9:~# docker | + | < |
| - | CONTAINER | + | docker@manager1:~$ docker |
| - | 21b0490a93dd | + | [ |
| + | { | ||
| + | "ID": " | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | "CreatedAt": | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | ] | ||
| + | }, | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | }, | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | } | ||
| + | ] | ||
| </ | </ | ||
| - | ainsi que l'image du registry | + | L'option **--pretty** produit une sortie plus facilement lisible |
| < | < | ||
| - | root@debian9:~# docker | + | docker@manager1:/$ docker |
| - | Untagged: registry: | + | ID: 1f5qtolgtonqmhjk5ppwc8x1b |
| - | Untagged: registry@sha256:3cac1869696e4ff3435bbc30391749ac373f7471736dbb48dfa9bfde08c4efd2 | + | Hostname: |
| - | Deleted: sha256:3bccd459597f38e78ce95a408e506099644ca713d79157d2f3e3a7975f1c9146 | + | Joined at: 2017-09-08 11:48:42.011596185 +0000 utc |
| - | Deleted: sha256: | + | Status: |
| - | Deleted: sha256:d206757aba612d90965729f186dfb70aa5e63b53dafd7e7b20a76005acddfe24 | + | State: Ready |
| - | Deleted: sha256: | + | Availability: Active |
| - | Deleted: sha256: | + | Address: 192.168.99.101 |
| - | Deleted: sha256: | + | Platform: |
| - | Deleted: sha256: | + | Operating System: linux |
| - | Deleted: sha256: | + | Architecture: x86_64 |
| - | Deleted: sha256: | + | Resources: |
| - | Deleted: sha256:6269effe5aa88dfc0071a2841605d95c0d809111333b5044b2459b43e5879f44 | + | CPUs: 1 |
| - | Deleted: sha256: | + | Memory: 995.8MiB |
| - | Deleted: sha256: | + | Plugins: |
| - | Deleted: sha256: | + | Log: awslogs, fluentd, gcplogs, gelf, journald, json-file, logentries, splunk, syslog |
| - | Deleted: sha256:518c6772b2fc316c63e9f4f9745e3587f169ec916fd26749b0ce7bf1f36bb93b | + | Network: bridge, host, macvlan, null, overlay |
| - | Deleted: sha256: | + | Volume: local |
| - | Deleted: sha256: | + | Engine Version: 17.06.2-ce |
| - | Deleted: sha256: | + | Engine Labels: |
| - | Deleted: sha256: | + | - provider=virtualbox |
| - | Deleted: sha256: | + | TLS Info: |
| - | Deleted: sha256: | + | TrustRoot: |
| - | Deleted: sha256: | + | -----BEGIN CERTIFICATE----- |
| - | Deleted: sha256: | + | MIIBajCCARCgAwIBAgIUNuU4I89kxId2QXulofRKxJa9XRcwCgYIKoZIzj0EAwIw |
| - | Deleted: sha256: | + | EzERMA8GA1UEAxMIc3dhcm0tY2EwHhcNMTcwOTA4MTEzOTAwWhcNMzcwOTAzMTEz |
| + | OTAwWjATMREwDwYDVQQDEwhzd2FybS1jYTBZMBMGByqGSM49AgEGCCqGSM49AwEH | ||
| + | A0IABEqgLUbyjyNuP35aAzW+aqVB8AkghvpF5hq1KnMveHbl4Ilr+EyDjlYZkbnt | ||
| + | Gb/ | ||
| + | Af8EBTADAQH/ | ||
| + | PQQDAgNIADBFAiB34DOvDtIYjJ+GzbPMGu9Dd/ | ||
| + | TJBucTomFSDsj5Y/ | ||
| + | -----END CERTIFICATE----- | ||
| - | root@debian9:~# docker images | + | |
| - | REPOSITORY | + | Issuer Public Key: |
| - | i2tch/mydocker | + | |
| - | localhost: | + | |
| </ | </ | ||
| - | Renommez l' | + | ====3.9 - Haute Disponibilité==== |
| + | |||
| + | Quand un nœud est actif, il est capable de recevoir de nouvelles tâches à partir du manager : | ||
| + | |||
| + | | ||
| + | | ||
| + | | ||
| + | * quand un service se mets en échec sur un autre nœud | ||
| + | |||
| + | Rappelez-vous que la swarm contient 6 VM Docker | ||
| < | < | ||
| - | root@debian9: | + | docker@manager1:~$ docker |
| - | root@debian9:~# docker | + | ID |
| - | REPOSITORY | + | y0war0lijmwhnexrfhfflulsd * |
| - | i2tch/ | + | v5ai62lmhfsdcauccqmjyu6qk |
| - | localhost: | + | j4mr3d2ji30t7hu0trob5dpgz |
| - | myregistry: | + | pouo7nuvirq0qkuvvrp04a47h |
| + | mo0dd5ech6ifdgd8pa6cjz896 | ||
| + | 5am2vd39pybytu1nd3oooabtq | ||
| </ | </ | ||
| - | Pour Trainee10 à Trainee19, éditez le fichier **/ | + | et que sur les 6 VM Docker, il y a 8 conteneurs, |
| < | < | ||
| - | root@debian9:~# vi /etc/hosts | + | docker@manager1:~$ docker service ps web |
| - | root@debian9: | + | ID NAME IMAGE |
| - | 127.0.0.1 localhost | + | son0vgc73drb |
| - | 10.0.2.60 debian9.i2tch.loc debian9 | + | ojqyweuo65jw |
| - | 10.0.2.61 myregistry.i2tch.loc | + | mb40onnaxd0u |
| - | 10.0.2.62 manager.i2tch.loc manager | + | 4vwsho5x7i36 |
| - | 10.0.2.63 worker1.i2tch.loc worker1 | + | sk9hr6j2u47c |
| - | 10.0.2.64 worker2.i2tch.loc worker2 | + | pui4dnkepu27 |
| - | + | yj0kexdcuo5u | |
| - | # The following lines are desirable for IPv6 capable hosts | + | 93jtbxqj2dyz |
| - | ::1 | + | |
| - | ff02::1 ip6-allnodes | + | |
| - | ff02::2 ip6-allrouters | + | |
| </ | </ | ||
| - | Pour Trainee20 à Trainee29, éditez le fichier **/ | + | dont deux se trouvent sur worker1 |
| < | < | ||
| - | root@debian9:~# vi /etc/hosts | + | docker@manager1:~$ docker node ps worker1 |
| - | root@debian9: | + | ID NAME IMAGE |
| - | 127.0.0.1 localhost | + | pui4dnkepu27 |
| - | 10.0.2.40 debian9.i2tch.loc debian9 | + | 93jtbxqj2dyz |
| - | 10.0.2.41 myregistry.i2tch.loc | + | </ |
| - | 10.0.2.42 manager.i2tch.loc manager | + | |
| - | 10.0.2.43 worker1.i2tch.loc worker1 | + | |
| - | 10.0.2.44 worker2.i2tch.loc worker2 | + | |
| - | # The following lines are desirable for IPv6 capable hosts | + | Mettez worker1 en mode d' |
| - | ::1 | + | |
| - | ff02::1 ip6-allnodes | + | < |
| - | ff02::2 ip6-allrouters | + | docker@manager1:~$ docker node update |
| + | worker1 | ||
| </ | </ | ||
| - | Déplacez | + | Constatez que le service web a été déplacé sur deux autres noeuds, |
| < | < | ||
| - | root@debian9:~# mkdir -p /etc/docker/certs.d/ | + | docker@manager1:~$ docker |
| - | root@debian9:~# mv /tmp/ca.crt / | + | ID NAME IMAGE |
| + | son0vgc73drb | ||
| + | ojqyweuo65jw | ||
| + | mb40onnaxd0u | ||
| + | 4vwsho5x7i36 | ||
| + | sk9hr6j2u47c | ||
| + | ag41oh489h4t | ||
| + | pui4dnkepu27 | ||
| + | yj0kexdcuo5u | ||
| + | kv7ax6cwzpkf | ||
| + | 93jtbxqj2dyz | ||
| </ | </ | ||
| - | Testez | + | ====3.10 - Supprimer un Service=== |
| + | |||
| + | Pour supprimer un service il convient d' | ||
| < | < | ||
| - | root@debian9:~# curl http:// | + | docker@manager1:~$ docker service rm web |
| - | + | web | |
| + | |||
| + | docker@manager1:~$ docker service ls | ||
| + | ID NAME MODE REPLICAS | ||
| + | |||
| + | docker@manager1:~$ docker service inspect web | ||
| + | [] | ||
| + | Status: Error: no such service: web, Code: 1 | ||
| </ | </ | ||
| - | Finalement, envoyez l' | + | ====3.11 - Sauvegarder Docker Swarm==== |
| + | |||
| + | La configuration de Docker Swarm est contenue dans le répertoire **/ | ||
| < | < | ||
| - | root@debian9:~# docker | + | docker@manager1: |
| - | The push refers to a repository [myregistry:5000/ | + | |
| - | 873a8ac77d4d: Pushed | + | root@manager1:~# ls -l /var/lib/docker/swarm |
| - | b362758f4793: Pushed | + | total 20 |
| - | latest: digest: sha256: | + | drwxr-xr-x |
| + | -rw------- | ||
| + | drwx------ | ||
| + | -rw------- | ||
| + | drwxr-xr-x | ||
| </ | </ | ||
| + | |||
| + | Le processus de sauvegarde necéssite qu'il y ait au moins **deux** Managers dans le Swarm. Le procédure de sauvegarde est : | ||
| + | |||
| + | * arrêt du service Docker sur le Manager à sauvegarder, | ||
| + | * sauvegarde du répertoire **/ | ||
| + | * redémarrage du service Docker sur le Manager concerné. | ||
| + | |||
| + | ====3.12 - Restaurer Docker Swarm==== | ||
| + | |||
| + | Le procédure de resturation est : | ||
| + | |||
| + | * arrêt du service Docker sur un nouveau Manager, | ||
| + | * suppression du contenu du répertoire **/ | ||
| + | * restauration du répertoire **/ | ||
| + | * exécution de la commande **docker swarm init --force-new-cluster** sur le nouveau Manager, | ||
| + | * ajout des Managers et Workers à Swarm. | ||
| ----- | ----- | ||
| - | < | + | |
| - | <div align=" | + | Copyright © 2024 Hugh Norris. |
| - | Copyright © 2021 Hugh NORRIS | + | |
| - | </ | + | |
| - | </ | + | |