Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
elearning:workbooks:docker3:drf04 [2021/11/21 11:41] – created adminelearning:workbooks:docker3:drf04 [2024/02/21 13:40] (Version actuelle) admin
Ligne 1: Ligne 1:
 ~~PDF:LANDSCAPE~~ ~~PDF:LANDSCAPE~~
  
-Version : **2021.01**+Version : **2024.01**
  
 Dernière mise-à-jour : ~~LASTMOD~~ Dernière mise-à-jour : ~~LASTMOD~~
  
-======DOF605 - Stocker les Images Docker======+======DOF605 - Docker Compose, Docker Machine et Docker Swarm======
  
 =====Contenu du Module===== =====Contenu du Module=====
  
-  * **DOF605 - Stocker les Images Docker**+  * **DOF605 - Docker Compose, Docker Machine et Docker Swarm**
     * 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 de Registre Dédié +      * 2.- Présentation 
-        Configurer le clone comme Registre Dédié +      * 2.2 - Création de Machines Virtuelles Docker 
-        Configurer le Client+      * 2.3 - Lister les VM Docker 
 +      * 2.4 - Obtenir l'adresse IP des VM 
 +      * 2.5 - Se connecter à une VM Docker 
 +    * LAB #3 - Docker Swarm 
 +      * 3.- Présentation 
 +      * 3.2 - Initialiser Docker Swarm 
 +      * 3.3 - Le Statut Leader 
 +      * 3.4 - Rejoindre le Swarm 
 +      * 3.5 - Consulter les Informations de Swarm 
 +      3.6 - Démarrer un Service 
 +      3.7 - Augmentation et Réduction du Service 
 +      * 3.8 - Consulter le Statut d'un Nœud 
 +      * 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====+Docker Compose est un utilitaire de compilation d'images et de gestion de conteneurs multiples, tous intégrés dans une seule et unique application logicielleSon rôle est de rendre plus aisée la manipulation d'éléments multiples interconnectés. Pour ce faire, Docker Compose utilise un fichier dénommé **docker-compose.yml** au format **YAML**.
  
-Docker n'est pas dans le dépôts de DebianAfin de l'installer il convient d'ajouter le dépôt de docker. Premièrement, il est nécessaire d'installer les paquets permettant à Debian d'utiliser un dépôt en https :+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 fichierLe reste du fichier contient des instructions pour définir la compilation des images constituantes, pour lier des conteneurs et pour définir l'environnement. 
 + 
 +Une fois totalement construite, l'application peut ensuite être pilotée très simplement par l'utilisation de la commande docker-compose qui réagit de la même manière que la commande **docker** mais cette fois-ci sur tous les conteneurs définis dans le fichier **docker-compose.yml**. 
 + 
 +De cette façon il est possible de démarrer l'application avec la commande **docker-compose up**, de l'arrêter avec la commande **docker-compose stop** ou de la redémarrer avec la commande **docker-compose restart**. De la même manière que la commande **docker**, la commande docker-compose donne accès aux journaux grâce à la commande **docker-compose logs**. 
 + 
 +====1.1 - Installation==== 
 + 
 +Récupérez docker-compose avec **curl** :
  
 <code> <code>
-root@debian9:~# apt-get update +root@debian11:~# curl -L "https://github.com/docker/compose/releases/download/v2.0.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose 
-... +  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current 
-root@debian9:~# apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common +                                 Dload  Upload   Total   Spent    Left  Speed 
-Reading package lists... Done +         0        0          0      0 --:--:-- --:--:-- --:--:--     0 
-Building dependency tree        +100 24.7M  100 24.7M    0      45.5M      0 --:--:-- --:--:-- --:--:-- 45.5M
-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] +
 </code> </code>
  
-Téléchargez la clef GPG officielle de docker :+Vérifiez la version installée :
  
 <code> <code>
-root@debian9:~# curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add +root@debian11:~# docker-compose --version 
-OK+Docker Compose version v2.0.1
 </code> </code>
  
-Vérifiez que l'ID de la clef est **9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88** :+Rendez **/usr/local/bin/docker-compose** exécutable :
  
 <code> <code>
-root@debian9:~# apt-key fingerprint 0EBFCD88 +root@debian11:~# chmod +x /usr/local/bin/docker-compose  
-/etc/apt/trusted.gpg + 
--------------------- +root@debian11:~# ls -l /usr/local/bin/docker-compose 
-pub   4096R/0EBFCD88 2017-02-22 +-rwxr-xr-x 1 root root 25907200 Dec 16 12:15 /usr/local/bin/docker-compose
-      Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88 +
-uid                  Docker Release (CE deb) <docker@docker.com> +
-sub   4096R/F273FCD8 2017-02-22 +
-...+
 </code> </code>
  
-Ajoutez le dépôt **stable** de docker :+Les options de la commande **docker-compose** sont :
  
 <code> <code>
-root@debian9:~# add-apt-repository "deb [arch=amd64https://download.docker.com/linux/debian $(lsb_release -cs) stable"+root@debian11:~# docker-compose --help 
 + 
 +Usage:  docker compose [OPTIONSCOMMAND 
 + 
 +Docker Compose 
 + 
 +Options: 
 +      --ansi string                Control when to print ANSI control 
 +                                   characters ("never"|"always"|"auto"
 +                                   (default "auto"
 +      --compatibility              Run compose in backward compatibility mode 
 +      --env-file string            Specify an alternate environment file. 
 +  -f, --file stringArray           Compose configuration files 
 +      --profile stringArray        Specify a profile to enable 
 +      --project-directory string   Specify an alternate working directory 
 +                                   (default: the path of the Compose file) 
 +  -p, --project-name string        Project name 
 + 
 +Commands: 
 +  build       Build or rebuild services 
 +  convert     Converts the compose file to platform's canonical format 
 +  cp          Copy files/folders between a service container and the local filesystem 
 +  create      Creates containers for a service. 
 +  down        Stop and remove containers, networks 
 +  events      Receive real time events from containers. 
 +  exec        Execute a command in a running container. 
 +  images      List images used by the created containers 
 +  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     Restart containers 
 +  rm          Removes stopped service containers 
 +  run         Run a one-off command on a service. 
 +  start       Start services 
 +  stop        Stop services 
 +  top         Display the running processes 
 +  unpause     unpause services 
 +  up          Create and start containers 
 + 
 +Run 'docker compose COMMAND --help' for more information on a command.
 </code> </code>
  
-<WRAP center round important> +====1.2 Installer Wordpress avec Docker Compose====
-**Important** Notez que la commande **lsb_release -cs** retourne le nom de la distribution Debian, à savoir dans ce cas **stretch**. +
-</WRAP>+
  
-Installez maintenant le paquet **docker-ce** :+Créez maintenant le répertoire **wordpress1** dans /root :
  
 <code> <code>
-root@debian9:~# apt-get update +root@debian9:~# mkdir wordpress1
-... +
-root@debian9:~# apt-get install docker-ce +
-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] +
 </code> </code>
  
-Dernièrement, vérifiez la version de Docker client et serveur :+Placez-vous dans le répertoire et créer le fichier **docker-compose.yaml**
  
 <code> <code>
-root@debian9:~# docker version +root@debian9:~# cd wordpress1 
-ClientDocker Engine Community +root@debian9:~/wordpress1# vi docker-compose.yaml 
- Version          19.03.4 +root@debian9:~/wordpress1# cat docker-compose.yaml 
- API version:       1.40 +version: "3.3" 
- Go version       go1.12.10 +     
- Git commit       9013bf583a +services
- Built            Fri Oct 18 15:52:34 2019 +  db
- OS/Arch          linux/amd64 +    imagemysql:5.7 
- Experimental     false +    volumes
- +      - db_data:/var/lib/mysql 
-ServerDocker Engine - Community +    restartalways 
- Engine+    environment: 
-  Version         19.03.4 +      MYSQL_ROOT_PASSWORDfenestros 
-  API version     1.40 (minimum version 1.12) +      MYSQL_DATABASEwordpress 
-  Go version      go1.12.10 +      MYSQL_USERwordpress 
-  Git commit      9013bf583a +      MYSQL_PASSWORDwordpress 
-  Built           Fri Oct 18 15:51:05 2019 +     
-  OS/Arch         linux/amd64 +  wordpress
-  Experimental    false +    depends_on
- containerd+      - db 
-  Version         1.2.10 +    imagewordpress:latest 
-  GitCommit       b34a5c8af56e510852c35414db4c1f4fa6172339 +    ports
- runc+      - "8000:80" 
-  Version         1.0.0-rc8+dev +    restartalways 
-  GitCommit       3e425f80a8c931f88e6d94a8c831b9d5aa481657 +    environment
- docker-init+      WORDPRESS_DB_HOSTdb:3306 
-  Version         0.18.0 +      WORDPRESS_DB_USERwordpress 
-  GitCommit       fec3683+      WORDPRESS_DB_PASSWORDwordpress 
 +      WORDPRESS_DB_NAMEwordpress 
 +volumes
 +  db_data{}
 </code> </code>
  
-<WRAP center round important> +Exécutez la commande docker-compose :
-**Important** Docker est composé de trois éléments un serveur, un client et un ou plusieurs **Repositories** ou Dépôts. Nous reviendrons sur les dépôts dans le détail plus tard dans ce cours. +
-</WRAP>+
  
-Re-démarrez la machine virtuelle avant de poursuivre :+<code> 
 +root@debian11:~/wordpress1# docker-compose up -d 
 +[+] Running 12/12 
 + ⠿ db Pulled                                                                                                                                                                                            16.0s 
 +   ⠿ 20e4dcae4c69 Pull complete                                                                                                                                                                          5.7s 
 +   ⠿ 1c56c3d4ce74 Pull complete                                                                                                                                                                          5.8s 
 +   ⠿ e9f03a1c24ce Pull complete                                                                                                                                                                          5.9s 
 +   ⠿ 68c3898c2015 Pull complete                                                                                                                                                                          6.2s 
 +   ⠿ 6b95a940e7b6 Pull complete                                                                                                                                                                          6.3s 
 +   ⠿ 90986bb8de6e Pull complete                                                                                                                                                                          6.3s 
 +   ⠿ ae71319cb779 Pull complete                                                                                                                                                                          7.4s 
 +   ⠿ ffc89e9dfd88 Pull complete                                                                                                                                                                          7.4s 
 +   ⠿ 43d05e938198 Pull complete                                                                                                                                                                         15.2s 
 +   ⠿ 064b2d298fba Pull complete                                                                                                                                                                         15.3s 
 +   ⠿ df9a4d85569b Pull complete                                                                                                                                                                         15.3s 
 +[+] Running 4/4 
 + ⠿ Network wordpress1_default        Created                                                                                                                                                             0.1s 
 + ⠿ Volume "wordpress1_db_data"       Created                                                                                                                                                             0.0s 
 + ⠿ Container wordpress1-db-1         Started                                                                                                                                                            10.7s 
 + ⠿ Container wordpress1-wordpress-1  Started                                                                                                                                                             1.5s 
 +</code> 
 + 
 +Vérifiez que le Wordpress fonctionne :
  
 <code> <code>
-root@debian9:~# shutdown -r now+root@debian11:~/wordpress1lynx --dump http://10.0.2.46:8000 
 +   WordPress 
 +   Select a default language [English (United States)__________] 
 + 
 +   Continue 
 +    
 +root@debian11:~/wordpress1# docker ps 
 +CONTAINER ID   IMAGE                                   COMMAND                  CREATED              STATUS          PORTS                                   NAMES 
 +9475874569e1   wordpress:latest                        "docker-entrypoint.s…"   51 seconds ago       Up 49 seconds   0.0.0.0:8000->80/tcp, :::8000->80/tcp   wordpress1-wordpress-1 
 +5983cdf711ec   mysql:5.7                               "docker-entrypoint.s…"   About a minute ago   Up 50 seconds   3306/tcp, 33060/tcp                     wordpress1-db-1 
 +cf27f30654d2   dockersamples/examplevotingapp_worker   "dotnet Worker.dll"      20 hours ago         Up 20 hours                                             worker 
 +33a264a36bdc   dockersamples/examplevotingapp_result   "/usr/bin/tini -- no…"   20 hours ago         Up 20 hours     0.0.0.0:5001->80/tcp, :::5001->80/tcp   result 
 +81e6fcb9f692   dockersamples/examplevotingapp_vote     "gunicorn app:app -b…"   20 hours ago         Up 20 hours     0.0.0.0:5000->80/tcp, :::5000->80/tcp   vote 
 +5083545dcbf8   postgres:9.4                            "docker-entrypoint.s…"   20 hours ago         Up 20 hours     5432/tcp                                db 
 +227554e3e4c1   redis                                   "docker-entrypoint.s…"   20 hours ago         Up 20 hours     6379/tcp                                redis 
 +63fec083f4d6   wordpress                               "docker-entrypoint.s…"   21 hours ago         Up 21 hours     10.0.2.46:80->80/tcp                    wordpress 
 +db3732939266   mysql:latest                            "docker-entrypoint.s…"   21 hours ago         Up 21 hours     3306/tcp, 33060/tcp                     wordpressdb 
 +57e92a8b25d7   centos                                  "/bin/bash"              21 hours ago         Up 21 hours                                             centos3 
 +fc417b22a20d   centos                                  "/bin/bash"              21 hours ago         Up 21 hours                                             centos2 
 +cb2875ab1059   centos                                  "/bin/bash"              21 hours ago         Up 21 hours                                             centos1 
 +2126924504d8   centos                                  "/bin/bash"              21 hours ago         Up 21 hours                                             resotest 
 + 
 +root@debian11:~/wordpress1# docker inspect wordpress1-wordpress-1 | grep IPAddress 
 +            "SecondaryIPAddresses": null, 
 +            "IPAddress": "", 
 +                    "IPAddress": "172.18.0.3", 
 +                     
 +root@debian11:~/wordpress1# lynx --dump http://172.18.0.3 
 +   WordPress 
 +   Select a default language [English (United States)__________] 
 + 
 +   Continue
 </code> </code>
  
-====1.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'option **-d** a le même effet de son homologue de la commande **docker**. 
 +</WRAP>
  
-Vous devez vous connecter à la machine virtuelle debian9 à partir d'un terminal de votre gateway :+=====LAB #2 - Docker Machine===== 
 + 
 +====2.1 - Présentation==== 
 + 
 +Docker Machine est un outil qui vous permet d'installer docker sur des hôtes virtuels et de gérer les hôtes en utilisant des commandes spécifiques à docker-machine. Il est donc possible d'utiliser cet outil pour créer des hôtes docker localement, sur le réseau, dans un data center ou dans le cloud (Azure, AWS, Digital Ocean par exemple). 
 + 
 +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/daemon docker et de configurer un client docker afin qu'il "parle" à votre machine hôte. 
 + 
 +Pour installer docker-machine sur votre VM **debian11**, utilisez la commande suivante :
  
 <code> <code>
-trainee@traineeXX:~$ ssh -l trainee 10.0.2.60+root@debian11:~/wordpress1# cd ~ 
 + 
 +root@debian11:~# curl -L https://github.com/docker/machine/releases/download/v0.16.2/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machine && chmod +x /tmp/docker-machine && cp /tmp/docker-machine /usr/local/bin/docker-machine 
 +  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current 
 +                                 Dload  Upload   Total   Spent    Left  Speed 
 +  0        0        0          0      0 --:--:-- --:--:-- --:--:--     0 
 +100 32.6M  100 32.6M    0      48.5M      0 --:--:-- --:--:-- --:--:-- 48.5M
 </code> </code>
  
-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'option **--driver** ou **-d** qui indique le fournisseur à utiliser : 
 + 
 +^ Fournisseur ^ driver ^ 
 +| [[https://aws.amazon.com/fr/|Amazon Web Services]] | [[https://docs.docker.com/machine/drivers/aws/|amazonec2]] | 
 +| [[https://www.digitalocean.com/|Digital Ocean]] | [[https://docs.docker.com/machine/drivers/digital-ocean/|digitalocean]] | 
 +| [[https://www.exoscale.ch/|Exoscale]] | [[https://docs.docker.com/machine/drivers/exoscale/|exoscale]] | 
 +| [[https://cloud.google.com/compute/?hl=fr|Google Compute Engine]] | [[https://cloud.google.com/compute/?hl=fr|google]] | 
 +| [[http://www.softlayer.com/fr|IBM Softlayer]] | [[https://docs.docker.com/machine/drivers/soft-layer/|softlayer]] | 
 +| [[https://msdn.microsoft.com/fr-fr/library/hh831531(v=ws.11).aspx|Microsoft Hyper-V]] | [[https://docs.docker.com/machine/drivers/digital-ocean/|hyperv]] | 
 +| [[https://azure.microsoft.com/fr-fr/|Microsoft Azure]] | [[https://docs.docker.com/machine/drivers/azure/|azure]] | 
 +| [[https://www.openstack.org/|OpenStack]] | [[https://docs.docker.com/machine/drivers/openstack/|openstack]] | 
 +| [[https://www.virtualbox.org/|Oracle VirtualBox]] | [[https://docs.docker.com/machine/drivers/digital-ocean/|virtualbox]] | 
 +| [[https://www.rackspace.com/en-gb|Rackspace]] | [[https://docs.docker.com/machine/drivers/rackspace/|rackspace]] | 
 +| [[https://www.vmware.com/fr/products/fusion.html|VMware Fusion]] | [[https://docs.docker.com/machine/drivers/vm-fusion/|vmwarefusion]] | 
 +| [[https://www.vmware.com/cloud-services/infrastructure.html|VMware vCloud Air]] | [[https://docs.docker.com/machine/drivers/vm-cloud/|vmwarevcloudair]] | 
 +| [[https://www.vmware.com/fr/products/vsphere.html|VMware vSphere]] | [[https://docs.docker.com/machine/drivers/vsphere/|vmwarevsphere]] | 
 + 
 +Commencez par installer Oracle VirtualBox:
  
 <code> <code>
-trainee@traineeXX:~$ ssh -l trainee 10.0.2.40+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' to remove them. 
 +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://download.virtualbox.org/virtualbox/debian bullseye/contrib amd64 virtualbox-6.1 amd64 6.1.48-159471~Debian~bullseye [95.8 MB] 
 +Fetched 95.8 MB in 3s (31.4 MB/s)           
 +apt-listchanges: Reading changelogs... 
 +Preconfiguring packages ... 
 +(Reading database ... 166797 files and directories currently installed.) 
 +Preparing to unpack .../virtualbox-6.1_6.1.48-159471~Debian~bullseye_amd64.deb ... 
 +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' already exists as a system group. Exiting. 
 +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) ...
 </code> </code>
  
-Passez en tant que **root** :+Créez le fichier **/etc/vbox/networks.conf** :
  
 <code> <code>
-trainee@debian9:~$ su - +root@debian11:~# vi /etc/vbox/networks.conf 
-Mot de passe : fenestros +root@debian11:~# cat /etc/vbox/networks.conf 
-root@debian9:~#+* 10.0.0.0/8 192.168.0.0/16
 </code> </code>
  
-Créez un répertoire nommé myDocker :+Créez maintenant la machine virtuelle **manager1** :
  
 <code> <code>
-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/.docker/machine/cache... 
 +(manager1) No default Boot2Docker ISO found locally, downloading the latest release... 
 +(manager1) Latest release for github.com/boot2docker/boot2docker is v19.03.12 
 +(manager1) Downloading /root/.docker/machine/cache/boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v19.03.12/boot2docker.iso... 
 +(manager1) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100% 
 +Creating machine... 
 +(manager1) Copying /root/.docker/machine/cache/boot2docker.iso to /root/.docker/machine/machines/manager1/boot2docker.iso... 
 +(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: "vboxnet0" 
 +(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
 </code> </code>
  
-Créez le fichier myEntrypoint.sh :+Les options de la commande **docker-machine** sont :
  
 <code> <code>
-root@debian9:~/myDockervi myEntrypoint.sh +root@debian11:~# docker-machine --help 
-root@debian9:~/myDocker# cat myEntrypoint.sh  +Usagedocker-machine [OPTIONS] COMMAND [arg...]
-#!/bin/bash +
-if -z "$myVariable" ]; then +
- echo "La variable myVariable doit être renseignée" +
- return 1 +
-fi+
  
-while true; +Create and manage machines running Docker.
-do +
- echo $1 \($(date +%H:%M:%S)\); +
- sleep "$myVariable"; +
-done +
-</code>+
  
-Testez ce script :+Version0.16.2, build bd45ab13
  
-<code> +Author: 
-root@debian9:~/myDocker# myVariable=3 . ./myEntrypoint.sh salut +  Docker Machine Contributors - <https://github.com/docker/machine>
-salut (20:04:39) +
-salut (20:04:42) +
-salut (20:04:45) +
-salut (20:04:48) +
-salut (20:04:51) +
-^C +
-root@debian9:~/myDocker#  +
-</code>+
  
-Rendez ce script exécutable :+Options: 
 +  --debug, -D                                   Enable debug mode 
 +  --storage-path, -s "/root/.docker/machine"    Configures storage path [$MACHINE_STORAGE_PATH] 
 +  --tls-ca-cert                                 CA to verify remotes against [$MACHINE_TLS_CA_CERT] 
 +  --tls-ca-key                                  Private key to generate certificates [$MACHINE_TLS_CA_KEY] 
 +  --tls-client-cert                             Client cert to use for TLS [$MACHINE_TLS_CLIENT_CERT] 
 +  --tls-client-key                              Private key used in client TLS auth [$MACHINE_TLS_CLIENT_KEY] 
 +  --github-api-token                            Token to use for requests to the Github API [$MACHINE_GITHUB_API_TOKEN] 
 +  --native-ssh                                  Use the native (Go-based) SSH implementation. [$MACHINE_NATIVE_SSH] 
 +  --bugsnag-api-token                           BugSnag API token for crash reporting [$MACHINE_BUGSNAG_API_TOKEN] 
 +  --help, -h                                    show help 
 +  --version, -v                                 print the version 
 +   
 +Commands: 
 +  active                Print which machine is active 
 +  config                Print the connection config for machine 
 +  create                Create a machine 
 +  env                   Display the commands to set up the environment for the Docker client 
 +  inspect               Inspect information about a machine 
 +  ip                    Get the IP address of a machine 
 +  kill                  Kill a machine 
 +  ls                    List machines 
 +  provision             Re-provision existing machines 
 +  regenerate-certs      Regenerate TLS Certificates for a machine 
 +  restart               Restart a machine 
 +  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                Get the status of a machine 
 +  stop                  Stop a machine 
 +  upgrade               Upgrade a machine to the latest version of Docker 
 +  url                   Get the URL of a machine 
 +  version               Show the Docker Machine version or a machine docker version 
 +  help                  Shows a list of commands or help for one command 
 +   
 +Run 'docker-machine COMMAND --help' for more information on a command. 
 +</code>  
 + 
 +Les options de la sous-commande **create** de la commande **docker-machine** sont :
  
 <code> <code>
-root@debian9:~/myDockerchmod u+x myEntrypoint.sh  +root@debian11:~# docker-machine create --help 
-</code>+Usage: docker-machine create [OPTIONS] [arg...]
  
-Créez maintenant le fichier **Dockerfile** dans le répertoire **~/myDocker** :+Create a machine 
 + 
 +Description: 
 +   Run 'docker-machine create --driver name --help' to include the create flags for that driver in the help text. 
 + 
 +Options: 
 +    
 +   --driver, -d "virtualbox"                                                                            Driver to create machine with. [$MACHINE_DRIVER] 
 +   --engine-env [--engine-env option --engine-env option]                                               Specify environment variables to set in the engine 
 +   --engine-insecure-registry [--engine-insecure-registry option --engine-insecure-registry option]     Specify insecure registries to allow with the created engine 
 +   --engine-install-url "https://get.docker.com"                                                        Custom URL to use for engine installation [$MACHINE_DOCKER_INSTALL_URL] 
 +   --engine-label [--engine-label option --engine-label option]                                         Specify labels for the created engine 
 +   --engine-opt [--engine-opt option --engine-opt option]                                               Specify arbitrary flags to include with the created engine in the form flag=value 
 +   --engine-registry-mirror [--engine-registry-mirror option --engine-registry-mirror option]           Specify registry mirrors to use [$ENGINE_REGISTRY_MIRROR] 
 +   --engine-storage-driver                                                                              Specify a storage driver to use with the engine 
 +   --swarm                                                                                              Configure Machine to join a Swarm cluster 
 +   --swarm-addr                                                                                         addr to advertise for Swarm (default: detect and use the machine IP) 
 +   --swarm-discovery                                                                                    Discovery service to use with Swarm 
 +   --swarm-experimental                                                                                 Enable Swarm experimental features 
 +   --swarm-host "tcp://0.0.0.0:3376"                                                                    ip/socket to listen on for Swarm master 
 +   --swarm-image "swarm:latest"                                                                         Specify Docker image to use for Swarm [$MACHINE_SWARM_IMAGE] 
 +   --swarm-join-opt [--swarm-join-opt option --swarm-join-opt option]                                   Define arbitrary flags for Swarm join 
 +   --swarm-master                                                                                       Configure Machine to be a Swarm master 
 +   --swarm-opt [--swarm-opt option --swarm-opt option]                                                  Define arbitrary flags for Swarm master 
 +   --swarm-strategy "spread"                                                                            Define a default scheduling strategy for Swarm 
 +   --tls-san [--tls-san option --tls-san option]                                                        Support extra SANs for TLS certs 
 +   --virtualbox-boot2docker-url                                                                         The URL of the boot2docker image. Defaults to the latest available version [$VIRTUALBOX_BOOT2DOCKER_URL] 
 +   --virtualbox-cpu-count "1"                                                                           number of CPUs for the machine (-1 to use the number of CPUs available) [$VIRTUALBOX_CPU_COUNT] 
 +   --virtualbox-disk-size "20000"                                                                       Size of disk for host in MB [$VIRTUALBOX_DISK_SIZE] 
 +   --virtualbox-host-dns-resolver                                                                       Use the host DNS resolver [$VIRTUALBOX_HOST_DNS_RESOLVER] 
 +   --virtualbox-hostonly-cidr "192.168.99.1/24"                                                         Specify the Host Only CIDR [$VIRTUALBOX_HOSTONLY_CIDR] 
 +   --virtualbox-hostonly-nicpromisc "deny"                                                              Specify the Host Only Network Adapter Promiscuous Mode [$VIRTUALBOX_HOSTONLY_NIC_PROMISC] 
 +   --virtualbox-hostonly-nictype "82540EM"                                                              Specify the Host Only Network Adapter Type [$VIRTUALBOX_HOSTONLY_NIC_TYPE] 
 +   --virtualbox-hostonly-no-dhcp                                                                        Disable the Host Only DHCP Server [$VIRTUALBOX_HOSTONLY_NO_DHCP] 
 +   --virtualbox-import-boot2docker-vm                                                                   The name of a Boot2Docker VM to import [$VIRTUALBOX_BOOT2DOCKER_IMPORT_VM] 
 +   --virtualbox-memory "1024"                                                                           Size of memory for host in MB [$VIRTUALBOX_MEMORY_SIZE] 
 +   --virtualbox-nat-nictype "82540EM"                                                                   Specify the Network Adapter Type [$VIRTUALBOX_NAT_NICTYPE] 
 +   --virtualbox-no-dns-proxy                                                                            Disable proxying all DNS requests to the host [$VIRTUALBOX_NO_DNS_PROXY] 
 +   --virtualbox-no-share                                                                                Disable the mount of your home directory [$VIRTUALBOX_NO_SHARE] 
 +   --virtualbox-no-vtx-check                                                                            Disable checking for the availability of hardware virtualization before the vm is started [$VIRTUALBOX_NO_VTX_CHECK] 
 +   --virtualbox-share-folder                                                                            Mount the specified directory instead of the default home location. Format: dir:name [$VIRTUALBOX_SHARE_FOLDER] 
 +   --virtualbox-ui-type "headless"                                                                      Specify the UI Type: (gui|sdl|headless|separate) [$VIRTUALBOX_UI_TYPE] 
 +</code>  
 + 
 +Créez maintenant 5 travailleurs - **worker1** jusqu'à **worker5** :
  
 <code> <code>
-root@debian9:~/myDockervi Dockerfile +root@debian11:~# docker-machine create --driver virtualbox worker1 
-root@debian9:~/myDocker# cat Dockerfile +Running pre-create checks... 
-FROM centos:latest +Creating machine... 
-MAINTAINER i2tch "infos@i2tch.eu" +(worker1) Copying /root/.docker/machine/cache/boot2docker.iso to /root/.docker/machine/machines/worker1/boot2docker.iso... 
-COPY myEntrypoint.sh /entrypoint.sh +(worker1) Creating VirtualBox VM... 
-ENV myVariable 3 +(worker1) Creating SSH key..
-ENTRYPOINT ["/entrypoint.sh"] +(worker1) Starting the VM... 
-CMD ["mycommand"]+(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
 </code> </code>
- 
-Générez maintenant l'image : 
  
 <code> <code>
-root@debian9:~/myDocker# docker build -t i2tch/mydocker . +root@debian11:~# docker-machine create --driver virtualbox worker2 
-Sending build context to Docker daemon  3.072kB +... 
-Step 1/6 : FROM centos:latest +root@debian11:~# docker-machine create --driver virtualbox worker3 
- ---> 9f38484d220f +... 
-Step 2/6 : MAINTAINER i2tch "infos@i2tch.eu" +root@debian11:~# docker-machine create --driver virtualbox worker4 
- ---> Running in 02c700ed04da +... 
-Removing intermediate container 02c700ed04da +root@debian11:~# docker-machine create --driver virtualbox worker5 
- ---> 4274107d52e2 +...
-Step 3/6 : COPY myEntrypoint.sh /entrypoint.sh +
- ---> 7a3923372768 +
-Step 4/6 ENV myVariable 3 +
- ---> Running in 3288bf6291ad +
-Removing intermediate container 3288bf6291ad +
- ---> 3edb630c1511 +
-Step 5/6 : ENTRYPOINT ["/entrypoint.sh"] +
- ---> Running in 8dcba2c41520 +
-Removing intermediate container 8dcba2c41520 +
- ---> 11962052539c +
-Step 6/6 CMD ["mycommand"+
- ---> Running in f891fbcfaad0 +
-Removing intermediate container f891fbcfaad0 +
- ---> 7925ba23abb2 +
-Successfully built 7925ba23abb2 +
-Successfully tagged i2tch/mydocker:latest+
 </code> </code>
  
-====1.3 - Installer un Registre Local====+====2.3 - Lister les VM Docker====
  
-Pour installer un registre privé, il convient d'utiliser une image publique de docker :+Pour lister les VM Docker ainsi que leurs états, il convient d'utilise la sous-commande **ls** de la commande **docker-machine** :
  
 <code> <code>
-root@debian9:~/bestp# cd .. +root@debian11:~# docker-machine ls 
-root@debian9:~# docker run -d --name registry -p 88:5000 registry:2.0 +NAME       ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER      ERRORS 
-Unable to find image 'registry:2.0' locally +manager1          virtualbox   Running   tcp://192.168.99.100:2376           v19.03.12    
-2.0Pulling from library/registry +worker1    -        virtualbox   Running   tcp://192.168.99.101:2376           v19.03.12    
-4d2e9ae40c41Pull complete  +worker2    -        virtualbox   Running   tcp://192.168.99.102:2376           v19.03.12    
-a3ed95caeb02Pull complete  +worker3    -        virtualbox   Running   tcp://192.168.99.103:2376           v19.03.12    
-7c8152785df5Pull complete  +worker4    -        virtualbox   Running   tcp://192.168.99.104:2376           v19.03.12    
-8b04aafd7cd8Pull complete  +worker5    -        virtualbox   Running   tcp://192.168.99.105:2376           v19.03.12   
-c97c75d2d42ePull complete  +
-4b3ef98bba76Pull complete  +
-edee0288d356Pull complete  +
-ea2a9399d365Pull complete  +
-ddf532273b60: Pull complete  +
-e9e91aa1843e: Pull complete  +
-6144b0ffbb4c: Pull complete  +
-Digest: sha256:3cac1869696e4ff3435bbc30391749ac373f7471736dbb48dfa9bfde08c4efd2 +
-Status: Downloaded newer image for registry:2.+
-c4c7cad999cdd77df78a21897bd11c4742a094c1c76a2134fbe4a4d2d92bff0e+
 </code> </code>
  
-Utilisez maintenant **lynx** à partir d'un terminal de votre machine **hôte Docker** pour vérifier que le registre est actif :+====2.4 - Obtenir l'adresse IP des VM==== 
 + 
 +Une autre façon d'obtenir les adresses IP des VM est d'utiliser la sous-commande **ip** :
  
 <code> <code>
-root@debian9:~# lynx --dump http://localhost:88/v2 +root@debian11:~# docker-machine ip manager1 
-{}root@debian9:~# +192.168.99.100 
 +root@debian11:~# docker-machine ip worker1 
 +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:~# docker-machine ip worker5 
 +192.168.99.105
 </code> </code>
  
-<WRAP center round important> +====2.5 Se connecter à une VM Docker====
-**Important** Notez la réponse du serveur est **{}** soit une liste JSON vide. +
-</WRAP>+
  
-Renommez l'image **i2tch/mydocker** afin de pointer vers le nouveau registre :+Pour se connecter à une VM Docker, il convient d'utiliser la sous-commande **ssh** de la commande **docker-machine** :
  
 <code> <code>
-root@debian9:~# docker tag i2tch/mydocker localhost:88/mydocker+root@debian11:~# docker-machine ssh manager1 
 +   ( '>'
 +  /) TC (\   Core is distributed with ABSOLUTELY NO WARRANTY. 
 + (/-_--_-\)           www.tinycorelinux.net 
 + 
 +docker@manager1:~$ exit 
 +logout 
 +root@debian11:~#
 </code> </code>
  
-<WRAP center round important> +<WRAP center round important 50%
-**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://boot2docker.io/|Boot2Docker]]**. Cette distribution est basée sur **[[http://tinycorelinux.net/|Tiny Core Linux]]**, s'exécute entièrement dans la mémoire vive, pèse 27 Mo et démarre en approximativement 5 secondes.
 </WRAP> </WRAP>
  
-Envoyez votre image **localhost:88/mydocker** sur ce nouveau registre :+Installez maintenant le paquet **mlocate** :
  
 <code> <code>
-root@debian9:~# docker push localhost:88/mydocker +root@debian11:~# apt install mlocate -y 
-The push refers to a repository [localhost:88/mydocker+Reading package lists... Done 
-873a8ac77d4d: Pushed  +Building dependency tree... Done 
-b362758f4793: Pushed  +Reading state information... Done 
-latest: digestsha256:30866da81d92d2a1015b869c596ddd6e188f33894c41d8effa2161e5c2862b1f size: 5531+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' to remove them. 
 +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://deb.debian.org/debian bullseye/main amd64 mlocate amd64 0.26-5 [98.3 kB
 +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 .../mlocate_0.26-5_amd64.deb ... 
 +Unpacking mlocate (0.26-5) ... 
 +Setting up mlocate (0.26-5) ... 
 +update-alternativesusing /usr/bin/mlocate to provide /usr/bin/locate (locate) in auto mode 
 +Adding group `mlocate' (GID 123) ... 
 +Done. 
 +Created symlink /etc/systemd/system/timers.target.wants/mlocate.timer → /lib/systemd/system/mlocate.timer. 
 +mlocate.service is a disabled or a static unit, not starting it. 
 +Processing triggers for man-db (2.9.4-2) ...
 </code> </code>
  
-Constatez maintenant la présence de l'image dans le registre :+Ayant été créées par root, les VM Docker ainsi que leurs fichiers associés sont stockés dans le répertoire **/root/.docker/machine/machines/** :
  
 <code> <code>
-root@debian9:~# lynx --dump http://localhost:88/v2/mydocker/tags/list +root@debian11:~# updatedb 
-{"name":"mydocker","tags":["latest"]}+ 
 +root@debian11:~# locate manager1 
 +/root/.docker/machine/machines/manager1 
 +/root/.docker/machine/machines/manager1/boot2docker.iso 
 +/root/.docker/machine/machines/manager1/ca.pem 
 +/root/.docker/machine/machines/manager1/cert.pem 
 +/root/.docker/machine/machines/manager1/config.json 
 +/root/.docker/machine/machines/manager1/disk.vmdk 
 +/root/.docker/machine/machines/manager1/id_rsa 
 +/root/.docker/machine/machines/manager1/id_rsa.pub 
 +/root/.docker/machine/machines/manager1/key.pem 
 +/root/.docker/machine/machines/manager1/manager1 
 +/root/.docker/machine/machines/manager1/server-key.pem 
 +/root/.docker/machine/machines/manager1/server.pem 
 +/root/.docker/machine/machines/manager1/manager1/Logs 
 +/root/.docker/machine/machines/manager1/manager1/manager1.vbox 
 +/root/.docker/machine/machines/manager1/manager1/manager1.vbox-prev 
 +/root/.docker/machine/machines/manager1/manager1/Logs/VBox.log
 </code> </code>
 +
 +=====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'utiliser la commande **docker swarm init** à partir de la VM Docker **manager1** en stipulant l'adresse IP de manager1 :
  
 <code> <code>
-root@debian9:~# docker images +root@debian11:~# docker-machine ssh manager1 
-REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE +   ( '>') 
-i2tch/mydocker          latest              c37edbd43993        45 minutes ago      193MB +  /) TC (\   Core is distributed with ABSOLUTELY NO WARRANTY. 
-localhost:88/mydocker   latest              c37edbd43993        45 minutes ago      193MB + (/-_--_-\)           www.tinycorelinux.net 
-registry                2.0                 3bccd459597f        2 years ago         549MB+ 
 +docker@manager1:~$ docker swarm init --advertise-addr 192.168.99.100 
 +Swarm initialized: current node (y0war0lijmwhnexrfhfflulsd) is now a manager. 
 + 
 +To add a worker to this swarm, run the following command: 
 + 
 +    docker swarm join --token SWMTKN-1-25tbmsyx452cuhpiedymuc8n9llo9jbjcbza93npdo35q1aaff-9teuxcpe09xw7v7xz1tnwpw4g 192.168.99.100:2377 
 + 
 +To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
 </code> </code>
  
-====1.4 - Créer un Serveur de Registre Dédié====+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, le registre privé créé ci-dessus n'est pas accessible à partir du réseau local car il est référencé par localhost. Il convient donc maintenant de mettre en place un serveur dédié.+====3.3 Le Statut Leader====
  
-Connectez-vous à la VM Debian_9_1 :+Consultez le statut de la VM Docker manager1 :
  
 <code> <code>
-trainee@traineeXX:~$ ssh -l trainee 10.0.2.61+docker@manager1:~$ docker node ls                                                                                                                                                                             
 +ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION 
 +y0war0lijmwhnexrfhfflulsd *   manager1            Ready               Active              Leader              19.03.12
 </code> </code>
  
-ou+A un instant t il ne peut y avoir q'un seul **Leader**. Il est possible de créer d'autres nœuds de gestion en le rejoignant à swarm en utilisant le token prévu à cet effet. Par contre ces nœuds de gestion restent en attente d'une éventuelle défaillance du Leader actuel. 
 + 
 +Pour connaître le token nécessaire pour rejoindre swarm en tant que nœud de gestion, saisissez la commande suivante :
  
 <code> <code>
-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
 </code> </code>
  
-En tant que root, modifiez le nom d'hôte de la machine :+====3.4 - Rejoindre le Swarm==== 
 + 
 +Rejoignez les 5 machines travailleurs à swarm en utilisant le token **worker** :
  
 <code> <code>
-trainee@debian91:~$ su +docker@manager1:~$ exit                                                                                                                                                                                       
-Mot de passe fenestros +logout 
-root@debian91:~# nmcli general hostname myregistry.i2tch.loc + 
-root@debian91:~# hostname +root@debian11:~# docker-machine ssh worker1 
-myregistry.i2tch.loc+   ( '>'
 +  /) TC (\   Core is distributed with ABSOLUTELY NO WARRANTY. 
 + (/-_--_-\)           www.tinycorelinux.net 
 + 
 +docker@worker1:~$ docker swarm join --token SWMTKN-1-25tbmsyx452cuhpiedymuc8n9llo9jbjcbza93npdo35q1aaff-9teuxcpe09xw7v7xz1tnwpw4g 192.168.99.100:2377 
 +This node joined a swarm as a worker. 
 + 
 +docker@worker1:~$ exit                                                                                                                                                                                        
 +logout 
 + 
 +root@debian11:~# docker-machine ssh worker2 
 +   ( '>'
 +  /) TC (\   Core is distributed with ABSOLUTELY NO WARRANTY. 
 + (/-_--_-\)           www.tinycorelinux.net 
 + 
 +docker@worker2:~$ docker swarm join --token SWMTKN-1-25tbmsyx452cuhpiedymuc8n9llo9jbjcbza93npdo35q1aaff-9teuxcpe09xw7v7xz1tnwpw4g 192.168.99.100:2377 
 +This node joined a swarm as a worker. 
 + 
 +docker@worker2:~$ exit                                                                                                                                                                                        
 +logout 
 + 
 +root@debian11:~# docker-machine ssh worker3 
 +   ( '>'
 +  /) TC (\   Core is distributed with ABSOLUTELY NO WARRANTY. 
 + (/-_--_-\)           www.tinycorelinux.net 
 + 
 +docker@worker3:~$ docker swarm join --token SWMTKN-1-25tbmsyx452cuhpiedymuc8n9llo9jbjcbza93npdo35q1aaff-9teuxcpe09xw7v7xz1tnwpw4g 192.168.99.100:2377 
 +This node joined a swarm as a worker. 
 + 
 +docker@worker3:~$ exit                                                                                                                                                                                        
 +logout 
 + 
 +root@debian11:~# docker-machine ssh worker4 
 +   ( '>'
 +  /) TC (\   Core is distributed with ABSOLUTELY NO WARRANTY. 
 + (/-_--_-\)           www.tinycorelinux.net 
 + 
 +docker@worker4:~$ docker swarm join --token SWMTKN-1-25tbmsyx452cuhpiedymuc8n9llo9jbjcbza93npdo35q1aaff-9teuxcpe09xw7v7xz1tnwpw4g 192.168.99.100:2377 
 +This node joined a swarm as a worker. 
 + 
 +docker@worker4:~$ exit                                                                                                                                                                                        
 +logout 
 + 
 +root@debian11:~# docker-machine ssh worker5 
 +   ( '>'
 +  /) TC (\   Core is distributed with ABSOLUTELY NO WARRANTY. 
 + (/-_--_-\)           www.tinycorelinux.net 
 + 
 +docker@worker5:~$ docker swarm join --token SWMTKN-1-25tbmsyx452cuhpiedymuc8n9llo9jbjcbza93npdo35q1aaff-9teuxcpe09xw7v7xz1tnwpw4g 192.168.99.100:2377 
 +This node joined a swarm as a worker. 
 + 
 +docker@worker5:~$ exit                                                                                                                                                                                        
 +logout 
 + 
 +root@debian11:~# 
 </code> </code>
  
-Installez Docker :+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'état des VM Docker peut être consulter en utilisant de nouveau la commande **docker node ls** :
  
 <code> <code>
-root@debian91:~# apt-get update +root@debian11:~# docker-machine ssh manager1 
-root@debian91:~# apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common +   ( '>') 
-root@debian91:~# curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - +  /) TC (\   Core is distributed with ABSOLUTELY NO WARRANTY. 
-root@debian91:~# add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" + (/-_--_-\)           www.tinycorelinux.net 
-root@debian91:~# apt-get update + 
-root@debian91:~# apt-get install docker-ce+docker@manager1:~docker node ls                                    
 +ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION 
 +y0war0lijmwhnexrfhfflulsd *   manager1            Ready               Active              Leader              19.03.12 
 +v5ai62lmhfsdcauccqmjyu6qk     worker1             Ready               Active                                  19.03.12 
 +j4mr3d2ji30t7hu0trob5dpgz     worker2             Ready               Active                                  19.03.12 
 +pouo7nuvirq0qkuvvrp04a47h     worker3             Ready               Active                                  19.03.12 
 +mo0dd5ech6ifdgd8pa6cjz896     worker4             Ready               Active                                  19.03.12 
 +5am2vd39pybytu1nd3oooabtq     worker5             Ready               Active                                  19.03.12
 </code> </code>
  
-Pour Trainee10 à Trainee19, éditez le fichier **/etc/hosts** et changez l'entrée pour l'adresse IP 10.0.2.61 :+Notez que vous ne pouvez pas utiliser cette commande à partir d'un travailleur :
  
 <code> <code>
-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 + (/-_--_-\)           www.tinycorelinux.net 
-10.0.2.64 worker2.i2tch.loc worker2+ 
 +docker@worker5:~$ docker node ls 
 +Error response from daemon: This node is not a swarm manager. Worker nodes can't be used to view or modify cluster statePlease run this command on a manager node or promote the current node to a manager. 
 + 
 +docker@worker5:~$ exit                                                                                                                                                                                        
 +logout 
 +exit status 1
  
-The following lines are desirable for IPv6 capable hosts +root@debian11:~#
-::1     localhost ip6-localhost ip6-loopback +
-ff02::1 ip6-allnodes +
-ff02::2 ip6-allrouters+
 </code> </code>
  
-Pour Trainee20 à Trainee29, éditez le fichier **/etc/hosts** et changez l'entrée pour l'adresse IP 10.0.2.41 :+====3.5 - Consulter les Informations de Swarm==== 
 + 
 +Il est possible de visualiser les informations concernant le swarm en utilisant la commande **docker info** :
  
 <code> <code>
-root@debian91:~# vi /etc/hosts +root@debian11:~# docker-machine ssh manager1 
-root@debian91:~# cat /etc/hosts +   ( '>'
-127.0.0.1 localhost +  /) TC (\   Core is distributed with ABSOLUTELY NO WARRANTY
-10.0.2.40 debian9.i2tch.loc debian9 + (/-_--_-\)           www.tinycorelinux.net 
-10.0.2.41 myregistry.i2tch.loc    myregistry + 
-10.0.2.42 manager.i2tch.loc manager +docker@manager1:~$ docker info 
-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     localhost ip6-localhost ip6-loopback + Containers
-ff02::1 ip6-allnodes +  Running
-ff02::2 ip6-allrouters+  Paused: 0 
 +  Stopped: 0 
 + Images:
 + Server Version: 19.03.12 
 + Storage Driver: overlay2 
 +  Backing Filesystem: extfs 
 +  Supports d_type: true 
 +  Native Overlay Diff: true 
 + Logging Driver: json-file 
 + Cgroup Driver: cgroupfs 
 + Plugins: 
 +  Volume: local 
 +  Network: bridge host ipvlan macvlan null overlay 
 +  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog 
 + Swarmactive 
 +  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: 
 +   Snapshot Interval: 10000 
 +   Number of Old Snapshots to Retain: 0 
 +   Heartbeat Tick: 1 
 +   Election Tick: 10 
 +  Dispatcher: 
 +   Heartbeat Period: 5 seconds 
 +  CA Configuration: 
 +   Expiry Duration: 3 months 
 +   Force Rotate: 0 
 +  Autolock Managers: false 
 +  Root Rotation In Progress: false 
 +  Node Address: 192.168.99.100 
 +  Manager Addresses: 
 +   192.168.99.100:2377 
 + Runtimes: runc 
 + Default Runtime: runc 
 + Init Binary: docker-init 
 + containerd version7ad184331fa3e55e52b890ea95e65ba581ae3429 
 + runc versiondc9208a3303feef5b3839f4323d9beb36df0a9dd 
 + init version: fec3683 
 + Security Options: 
 +  seccomp 
 +   Profile: default 
 + Kernel Version: 4.19.130-boot2docker 
 + Operating System: Boot2Docker 19.03.12 (TCL 10.1) 
 + OSType: linux 
 + Architecture: x86_64 
 + CPUs: 1 
 + Total Memory: 985.4MiB 
 + Name: manager1 
 + ID: UIL3:SNFZ:J2XE:4QVD:7XYM:MPB7:2LHC:NMY7:B4CU:QMUK:3A66:H3G6 
 + Docker Root Dir: /mnt/sda1/var/lib/docker 
 + Debug Mode: false 
 + Registry: https://index.docker.io/v1/ 
 + Labels: 
 +  provider=virtualbox 
 + Experimental: false 
 + Insecure Registries: 
 +  127.0.0.0/
 + Live Restore Enabled: false 
 + Product License: Community Engine
 </code> </code>
  
-Créez maintenant un certificat auto-signé avec **openssl** :+<WRAP center round important 50%> 
 +**Important** Quand le moteur Docker est en mode swarm, les noeuds de gestion implémentent le **[[https://docs.docker.com/engine/swarm/raft/|Raft Consensus Algorithm]]** pour gérer l'état du cluster. 
 +</WRAP> 
 + 
 +====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**.
  
 <code> <code>
-root@debian91:~# cd / && mkdir certs && openssl req -newkey rsa:4096 -nodes -sha256 -keyout certs/domain.key -x509 -days 365 -out certs/domain.crt +docker@manager1:~$ docker service create --replicas 5 -p 80:80 --name web nginx                                                                                                                               
-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/5running   [==================================================>]  
-You are about to be asked to enter information that will be incorporated +4/5running   [==================================================>]  
-into your certificate request. +5/5running   [==================================================>]  
-What you are about to enter is what is called a Distinguished Name or a DN. +verifyService 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 '.', the field will be left blank. +
------ +
-Country Name (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) []:TRAINING +
-Common Name (e.g. server FQDN or YOUR name) []:myregistry +
-Email Address []: +
-root@registry:/# ls certs/ +
-domain.crt  domain.key+
 </code> </code>
  
-Créez un conteneur en mode sécurisé avec TLS à partir de l'image registry :+Pour consulter l'état de ce service, utilisez la commande **docker service ls** :
  
 <code> <code>
-root@registry:/# docker run -d -p 5000:5000 --name registry -v `pwd`/certs:/certs -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key registry:2.0 +docker@manager1:~$ docker service ls                                                                                                                                                                          
-943c01b67cf3f461270a55ac3d9df6622cc9d74e5f272e17153183ff29ee5932 +ID                  NAME                MODE                REPLICAS            IMAGE               PORTS 
-root@debian9:/+oree977o1unl        web                 replicated          5/5                 nginx:latest        *:80->80/tcp 
 +</code>
  
-root@registry:/# docker ps -a +Ce service fonctionne dans des conteneurs Docker : 
-CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                        PORTS                    NAMES + 
-943c01b67cf3        registry:2.       "registry cmd/regi..."   31 seconds ago      Up 24 seconds                 0.0.0.0:5000->5000/tcp   registry+<code> 
 +docker@manager1:~$ docker service ps web                                                                                                                                                                      
 +ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE            ERROR               PORTS 
 +son0vgc73drb        web.1               nginx:latest        worker4             Running             Running 48 seconds ago                        
 +ojqyweuo65jw        web.2               nginx:latest        worker5             Running             Running 49 seconds ago                        
 +mb40onnaxd0u        web.3               nginx:latest        manager1            Running             Running 49 seconds ago                        
 +4vwsho5x7i36        web.4               nginx:latest        worker2             Running             Running 49 seconds ago                        
 +sk9hr6j2u47c        web.5               nginx:latest        worker3             Running             Running 50 seconds ago 
 </code> </code>
  
-Envoyez une copie du fichier **/certs/domain.crt** vers le répertoire /tmp de la machine virtuelle **Debian_9** en le renommant **ca.crt** :+<WRAP center round important 50%> 
 +**Important** - Notez qu'il n'y a pas de conteneur sur worker1. 
 +</WRAP> 
 + 
 +Pour constater le lancement du daemon nginx, lancez la commande **docker ps** sur la machine **manager1** :
  
 <code> <code>
-root@debian91:~# scp /certs/domain.crt trainee@10.0.2.60:/tmp/ca.crt +docker@manager1:~$ docker ps                                                                                                                                                                                  
-The authenticity of host '10.0.2.60 (10.0.2.60)' can't be established. +CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS               NAMES 
-ECDSA key fingerprint is 79:00:60:0e:2b:71:5e:cb:1a:08:45:e8:ab:45:b8:dd. +244fecd46312        nginx:latest        "/docker-entrypoint.…"   About a minute ago   Up About a minute   80/tcp              web.3.mb40onnaxd0u8t0nhbzx9rdih
-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's password: trainee +
-domain.crt                                                                                                                            100% 2017     2.0KB/  00:00  +
 </code> </code>
  
-ou :+Par contre la même commande exécutée sur **worker1** donne le résultat suivant :
  
 <code> <code>
-root@debian91:~# scp /certs/domain.crt trainee@10.0.2.40:/tmp/ca.crt +docker@manager1:~$ exit                                                                                                                                                                                       
-The authenticity of host '10.0.2.40 (10.0.2.40)can't be established. +logout 
-ECDSA key fingerprint is 79:00:60:0e:2b:71:5e:cb:1a:08:45:e8:ab:45:b8:dd+ 
-Are you sure you want to continue connecting (yes/no)? yes +root@debian11:~# docker-machine ssh worker1 
-Warning: Permanently added '10.0.2.40' (ECDSA) to the list of known hosts+   ( '>') 
-trainee@10.0.2.40's passwordtrainee +  /) TC (\   Core is distributed with ABSOLUTELY NO WARRANTY
-domain.crt                                                                                                                            100% 2017     2.0KB/  00:00  + (/-_--_-\          www.tinycorelinux.net 
 + 
 +docker@worker1:~$ docker ps 
 +CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES 
 +docker@worker1:~$ exit                                                                                                                                                                                        
 +logout 
 + 
 +root@debian11:~#
 </code> </code>
  
-===Configurer le Client===+Connectez-vous sur chaque VM Docker pour constater que le service nginx fonctionne :
  
-Sortez de la VM **debian91** et connectez-vous à la VM debian9 :+<code> 
 +root@debian11:~# docker-machine ssh manager1 
 +   ( '>'
 +  /) TC (\   Core is distributed with ABSOLUTELY NO WARRANTY. 
 + (/-_--_-\)           www.tinycorelinux.net 
 + 
 +docker@manager1:~$ curl 192.168.99.100 
 +<!DOCTYPE html> 
 +<html> 
 +<head> 
 +<title>Welcome to nginx!</title> 
 +<style> 
 +html { color-scheme: light dark; } 
 +body { width: 35em; margin: 0 auto; 
 +font-family: Tahoma, Verdana, Arial, sans-serif; } 
 +</style> 
 +</head> 
 +<body> 
 +<h1>Welcome to nginx!</h1> 
 +<p>If you see this page, the nginx web server is successfully installed and 
 +working. Further configuration is required.</p> 
 + 
 +<p>For online documentation and support please refer to 
 +<a href="http://nginx.org/">nginx.org</a>.<br/> 
 +Commercial support is available at 
 +<a href="http://nginx.com/">nginx.com</a>.</p> 
 + 
 +<p><em>Thank you for using nginx.</em></p> 
 +</body> 
 +</html> 
 + 
 +docker@manager1:~$ curl 192.168.99.101                                                                                                                                                                        
 +<!DOCTYPE html> 
 +<html> 
 +<head> 
 +<title>Welcome to nginx!</title> 
 +<style> 
 +html { color-scheme: light dark; } 
 +body { width: 35em; margin: 0 auto; 
 +font-family: Tahoma, Verdana, Arial, sans-serif; } 
 +</style> 
 +</head> 
 +<body> 
 +<h1>Welcome to nginx!</h1> 
 +<p>If you see this page, the nginx web server is successfully installed and 
 +working. Further configuration is required.</p> 
 + 
 +<p>For online documentation and support please refer to 
 +<a href="http://nginx.org/">nginx.org</a>.<br/> 
 +Commercial support is available at 
 +<a href="http://nginx.com/">nginx.com</a>.</p> 
 + 
 +<p><em>Thank you for using nginx.</em></p> 
 +</body> 
 +</html> 
 + 
 +docker@manager1:~$ curl 192.168.99.102                                                                                                                                                                        
 +<!DOCTYPE html> 
 +<html> 
 +<head> 
 +<title>Welcome to nginx!</title> 
 +<style> 
 +html { color-scheme: light dark; } 
 +body { width: 35em; margin: 0 auto; 
 +font-family: Tahoma, Verdana, Arial, sans-serif; } 
 +</style> 
 +</head> 
 +<body> 
 +<h1>Welcome to nginx!</h1> 
 +<p>If you see this page, the nginx web server is successfully installed and 
 +working. Further configuration is required.</p> 
 + 
 +<p>For online documentation and support please refer to 
 +<a href="http://nginx.org/">nginx.org</a>.<br/> 
 +Commercial support is available at 
 +<a href="http://nginx.com/">nginx.com</a>.</p> 
 + 
 +<p><em>Thank you for using nginx.</em></p> 
 +</body> 
 +</html> 
 + 
 +docker@manager1:~$ curl 192.168.99.103                                                                                                                                                                        
 +<!DOCTYPE html> 
 +<html> 
 +<head> 
 +<title>Welcome to nginx!</title> 
 +<style> 
 +html { color-scheme: light dark; } 
 +body { width: 35em; margin: 0 auto; 
 +font-family: Tahoma, Verdana, Arial, sans-serif; } 
 +</style> 
 +</head> 
 +<body> 
 +<h1>Welcome to nginx!</h1> 
 +<p>If you see this page, the nginx web server is successfully installed and 
 +working. Further configuration is required.</p> 
 + 
 +<p>For online documentation and support please refer to 
 +<a href="http://nginx.org/">nginx.org</a>.<br/> 
 +Commercial support is available at 
 +<a href="http://nginx.com/">nginx.com</a>.</p> 
 + 
 +<p><em>Thank you for using nginx.</em></p> 
 +</body> 
 +</html> 
 + 
 +docker@manager1:~$ curl 192.168.99.104                                                                                                                                                                        
 +<!DOCTYPE html> 
 +<html> 
 +<head> 
 +<title>Welcome to nginx!</title> 
 +<style> 
 +html { color-scheme: light dark; } 
 +body { width: 35em; margin: 0 auto; 
 +font-family: Tahoma, Verdana, Arial, sans-serif; } 
 +</style> 
 +</head> 
 +<body> 
 +<h1>Welcome to nginx!</h1> 
 +<p>If you see this page, the nginx web server is successfully installed and 
 +working. Further configuration is required.</p> 
 + 
 +<p>For online documentation and support please refer to 
 +<a href="http://nginx.org/">nginx.org</a>.<br/> 
 +Commercial support is available at 
 +<a href="http://nginx.com/">nginx.com</a>.</p> 
 + 
 +<p><em>Thank you for using nginx.</em></p> 
 +</body> 
 +</html> 
 + 
 +docker@manager1:~$ curl 192.168.99.105                                                                                                                                                                        
 +<!DOCTYPE html> 
 +<html> 
 +<head> 
 +<title>Welcome to nginx!</title> 
 +<style> 
 +html { color-scheme: light dark; } 
 +body { width: 35em; margin: 0 auto; 
 +font-family: Tahoma, Verdana, Arial, sans-serif; } 
 +</style> 
 +</head> 
 +<body> 
 +<h1>Welcome to nginx!</h1> 
 +<p>If you see this page, the nginx web server is successfully installed and 
 +working. Further configuration is required.</p> 
 + 
 +<p>For online documentation and support please refer to 
 +<a href="http://nginx.org/">nginx.org</a>.<br/> 
 +Commercial support is available at 
 +<a href="http://nginx.com/">nginx.com</a>.</p> 
 + 
 +<p><em>Thank you for using nginx.</em></p> 
 +</body> 
 +</html> 
 +</code> 
 + 
 +<WRAP center round important 50%> 
 +**Important** - Notez que le service est même disponible en consultant l'adresse IP de worker1. 
 +</WRAP> 
 + 
 +====3.7 - Augmentation et Réduction du Service==== 
 + 
 +Actuellement, il existe 5 conteneurs en cours d'exécution. Pour procéder à un scale-up à 8 conteneurs, il convient d'utiliser la commande **docker service scale** :
  
 <code> <code>
-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 
 </code> </code>
  
-ou+Notez que la commande **docker service ls** confirme le fait qu'il y a 8 replicas :
  
 <code> <code>
-trainee@traineeXX:~$ ssh -l trainee 10.0.2.40+docker@manager1:~$ docker service ls                                                                                                                                                                          
 +ID                  NAME                MODE                REPLICAS            IMAGE               PORTS 
 +oree977o1unl        web                 replicated          8/8                 nginx:latest        *:80->80/tcp
 </code> </code>
  
-Passez en tant que **root** :+Des trois replicas supplémentaires, deux ont été lancés sur worker5 tandis que le troisième a été lancé sur worker1 :
  
 <code> <code>
-trainee@debian9:~$ su - +docker@manager1:~$ docker service ps web                                                                                                                                                                      
-Mot de passe fenestros +ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE                ERROR               PORTS 
-root@debian9:~#+son0vgc73drb        web.1               nginx:latest        worker4             Running             Running 9 minutes ago                             
 +ojqyweuo65jw        web.2               nginx:latest        worker5             Running             Running 9 minutes ago                             
 +mb40onnaxd0u        web.3               nginx:latest        manager1            Running             Running 9 minutes ago                             
 +4vwsho5x7i36        web.4               nginx:latest        worker2             Running             Running 9 minutes ago                             
 +sk9hr6j2u47c        web.5               nginx:latest        worker3             Running             Running 9 minutes ago                             
 +pui4dnkepu27        web.6               nginx:latest        worker1             Running             Running about a minute ago                        
 +yj0kexdcuo5u        web.7               nginx:latest        worker5             Running             Running about a minute ago                        
 +93jtbxqj2dyz        web.8               nginx:latest        worker1             Running             Running about a minute ago 
 </code> </code>
  
-Supprimez le conteneur **registry** :+====3.8 - Consulter le Statut d'un Noeud==== 
 + 
 +Pour se renseigner sur le statut du nœud courant, il convient d'utiliser la commande **docker node inspect** avec le mot clef **self** :
  
 <code> <code>
-root@debian9:~docker ps -a +docker@manager1:~docker node inspect self                                                                                                                                                                   
-CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                     PORTS               NAMES +
-c4c7cad999cd        registry:2.       "registry cmd/regi..."   4 hours ago         Exited (2) 4 hours ago                         registry +    { 
-21b0490a93dd        i2tch/mydocker      "/entrypoint.sh my..."   4 hours ago         Exited (137) 4 hours ago                       myDocker+        "ID": "y0war0lijmwhnexrfhfflulsd", 
 +        "Version":
 +            "Index": 9 
 +        }, 
 +        "CreatedAt""2023-12-16T13:38:18.600836601Z", 
 +        "UpdatedAt": "2023-12-16T13:38:19.126257379Z", 
 +        "Spec":
 +            "Labels": {}, 
 +            "Role": "manager", 
 +            "Availability": "active" 
 +        }, 
 +        "Description":
 +            "Hostname": "manager1", 
 +            "Platform":
 +                "Architecture": "x86_64", 
 +                "OS": "linux" 
 +            }, 
 +            "Resources":
 +                "NanoCPUs": 1000000000, 
 +                "MemoryBytes": 1033252864 
 +            }, 
 +            "Engine":
 +                "EngineVersion": "19.03.12", 
 +                "Labels":
 +                    "provider": "virtualbox" 
 +                }, 
 +                "Plugins":
 +                    { 
 +                        "Type": "Log", 
 +                        "Name": "awslogs" 
 +                    }, 
 +                    { 
 +                        "Type": "Log", 
 +                        "Name": "fluentd" 
 +                    }, 
 +                    { 
 +                        "Type": "Log", 
 +                        "Name": "gcplogs" 
 +                    }, 
 +                    { 
 +                        "Type": "Log", 
 +                        "Name": "gelf" 
 +                    }, 
 +                    { 
 +                        "Type": "Log", 
 +                        "Name": "journald" 
 +                    }, 
 +                    { 
 +                        "Type": "Log", 
 +                        "Name": "json-file" 
 +                    }, 
 +                    { 
 +                        "Type": "Log", 
 +                        "Name": "local" 
 +                    }, 
 +                    { 
 +                        "Type": "Log", 
 +                        "Name": "logentries" 
 +                    }, 
 +                    { 
 +                        "Type": "Log", 
 +                        "Name": "splunk" 
 +                    }, 
 +                    { 
 +                        "Type": "Log", 
 +                        "Name": "syslog" 
 +                    }, 
 +                    { 
 +                        "Type": "Network", 
 +                        "Name": "bridge" 
 +                    }, 
 +                    { 
 +                        "Type": "Network", 
 +                        "Name": "host" 
 +                    }, 
 +                    { 
 +                        "Type": "Network", 
 +                        "Name": "ipvlan" 
 +                    }, 
 +                    { 
 +                        "Type": "Network", 
 +                        "Name": "macvlan" 
 +                    }, 
 +                    { 
 +                        "Type": "Network", 
 +                        "Name": "null" 
 +                    }, 
 +                    { 
 +                        "Type": "Network", 
 +                        "Name": "overlay" 
 +                    }, 
 +                    { 
 +                        "Type": "Volume", 
 +                        "Name": "local" 
 +                    } 
 +                ] 
 +            }, 
 +            "TLSInfo":
 +                "TrustRoot": "-----BEGIN CERTIFICATE-----\nMIIBazCCARCgAwIBAgIUbi2tpJHqoqK+BA/p9c+Y9AmtQSAwCgYIKoZIzj0EAwIw\nEzERMA8GA1UEAxMIc3dhcm0tY2EwHhcNMjMxMjE2MTMzMzAwWhcNNDMxMjExMTMz\nMzAwWjATMREwDwYDVQQDEwhzd2FybS1jYTBZMBMGByqGSM49AgEGCCqGSM49AwEH\nA0IABKuD7Svum+bER9CszNtFt7ASMr5gj6Vea0oM7SCrlyYMCn8ryaHXQ9J+iEIh\nfWrpKmjNtei3/j+leOVF0flpg2OjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMB\nAf8EBTADAQH/MB0GA1UdDgQWBBRqlCTTUy9JODtzaVecgmjID/M5kzAKBggqhkjO\nPQQDAgNJADBGAiEA06sGunqGwd23lyjcUoczMWGQGln9nv0pmm/riJQvB80CIQC9\nvXNZUbC6U5lSQ7eGhfmmHi1JAfb88wGau0AlreBczw==\n-----END CERTIFICATE-----\n", 
 +                "CertIssuerSubject": "MBMxETAPBgNVBAMTCHN3YXJtLWNh", 
 +                "CertIssuerPublicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEq4PtK+6b5sRH0KzM20W3sBIyvmCPpV5rSgztIKuXJgwKfyvJoddD0n6IQiF9aukqaM216Lf+P6V45UXR+WmDYw==" 
 +            } 
 +        }, 
 +        "Status":
 +            "State": "ready", 
 +            "Addr": "192.168.99.100" 
 +        }, 
 +        "ManagerStatus":
 +            "Leader": true, 
 +            "Reachability": "reachable", 
 +            "Addr": "192.168.99.100:2377" 
 +        } 
 +    } 
 +
 +</code>
  
-root@debian9:~# docker rm registry +Pour se renseigner sur le statut d'un autre nœud, il convient d'utiliser la commande **docker node inspect** avec le nom du nœud concerné :
-registry+
  
-root@debian9:~docker ps -a +<code> 
-CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                     PORTS               NAMES +docker@manager1:~docker node inspect worker1                                                                                                                                                                
-21b0490a93dd        i2tch/mydocker      "/entrypoint.sh my..."   4 hours ago         Exited (137) 4 hours ago                       myDocker+
 +    { 
 +        "ID": "v5ai62lmhfsdcauccqmjyu6qk", 
 +        "Version":
 +            "Index": 15 
 +        }, 
 +        "CreatedAt": "2023-12-16T13:40:08.301827885Z", 
 +        "UpdatedAt": "2023-12-16T13:40:08.453463845Z", 
 +        "Spec":
 +            "Labels": {}, 
 +            "Role": "worker", 
 +            "Availability": "active" 
 +        }, 
 +        "Description":
 +            "Hostname": "worker1", 
 +            "Platform":
 +                "Architecture": "x86_64", 
 +                "OS": "linux" 
 +            }, 
 +            "Resources":
 +                "NanoCPUs": 1000000000, 
 +                "MemoryBytes": 1033252864 
 +            }, 
 +            "Engine":
 +                "EngineVersion": "19.03.12"
 +                "Labels":
 +                    "provider": "virtualbox" 
 +                }, 
 +                "Plugins":
 +                    { 
 +                        "Type": "Log", 
 +                        "Name": "awslogs" 
 +                    }, 
 +                    { 
 +                        "Type": "Log", 
 +                        "Name": "fluentd" 
 +                    }, 
 +                    { 
 +                        "Type": "Log", 
 +                        "Name": "gcplogs" 
 +                    }, 
 +                    { 
 +                        "Type": "Log", 
 +                        "Name": "gelf" 
 +                    }, 
 +                    { 
 +                        "Type": "Log", 
 +                        "Name": "journald" 
 +                    }, 
 +                    { 
 +                        "Type": "Log", 
 +                        "Name": "json-file" 
 +                    }, 
 +                    { 
 +                        "Type": "Log", 
 +                        "Name": "local" 
 +                    }, 
 +                    { 
 +                        "Type": "Log", 
 +                        "Name": "logentries" 
 +                    }, 
 +                    { 
 +                        "Type": "Log", 
 +                        "Name": "splunk" 
 +                    }, 
 +                    { 
 +                        "Type": "Log", 
 +                        "Name": "syslog" 
 +                    }, 
 +                    { 
 +                        "Type": "Network", 
 +                        "Name": "bridge" 
 +                    }, 
 +                    { 
 +                        "Type": "Network", 
 +                        "Name": "host" 
 +                    }, 
 +                    { 
 +                        "Type": "Network", 
 +                        "Name": "ipvlan" 
 +                    }, 
 +                    { 
 +                        "Type": "Network", 
 +                        "Name": "macvlan" 
 +                    }, 
 +                    { 
 +                        "Type": "Network", 
 +                        "Name": "null" 
 +                    }, 
 +                    { 
 +                        "Type": "Network", 
 +                        "Name": "overlay" 
 +                    }, 
 +                    { 
 +                        "Type": "Volume", 
 +                        "Name": "local" 
 +                    } 
 +                ] 
 +            }, 
 +            "TLSInfo":
 +                "TrustRoot": "-----BEGIN CERTIFICATE-----\nMIIBazCCARCgAwIBAgIUbi2tpJHqoqK+BA/p9c+Y9AmtQSAwCgYIKoZIzj0EAwIw\nEzERMA8GA1UEAxMIc3dhcm0tY2EwHhcNMjMxMjE2MTMzMzAwWhcNNDMxMjExMTMz\nMzAwWjATMREwDwYDVQQDEwhzd2FybS1jYTBZMBMGByqGSM49AgEGCCqGSM49AwEH\nA0IABKuD7Svum+bER9CszNtFt7ASMr5gj6Vea0oM7SCrlyYMCn8ryaHXQ9J+iEIh\nfWrpKmjNtei3/j+leOVF0flpg2OjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMB\nAf8EBTADAQH/MB0GA1UdDgQWBBRqlCTTUy9JODtzaVecgmjID/M5kzAKBggqhkjO\nPQQDAgNJADBGAiEA06sGunqGwd23lyjcUoczMWGQGln9nv0pmm/riJQvB80CIQC9\nvXNZUbC6U5lSQ7eGhfmmHi1JAfb88wGau0AlreBczw==\n-----END CERTIFICATE-----\n", 
 +                "CertIssuerSubject": "MBMxETAPBgNVBAMTCHN3YXJtLWNh", 
 +                "CertIssuerPublicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEq4PtK+6b5sRH0KzM20W3sBIyvmCPpV5rSgztIKuXJgwKfyvJoddD0n6IQiF9aukqaM216Lf+P6V45UXR+WmDYw==" 
 +            } 
 +        }, 
 +        "Status":
 +            "State": "ready", 
 +            "Addr": "192.168.99.101" 
 +        } 
 +    } 
 +]
 </code> </code>
  
-ainsi que l'image du registry :+L'option **--pretty** produit une sortie plus facilement lisible :
  
 <code> <code>
-root@debian9:~# docker rmi registry:2.0 +docker@manager1:/$ docker node inspect --pretty worker1 
-Untaggedregistry:2.0 +ID:             1f5qtolgtonqmhjk5ppwc8x1b 
-Untagged: registry@sha256:3cac1869696e4ff3435bbc30391749ac373f7471736dbb48dfa9bfde08c4efd2 +Hostname              worker1 
-Deletedsha256:3bccd459597f38e78ce95a408e506099644ca713d79157d2f3e3a7975f1c9146 +Joined at            2017-09-08 11:48:42.011596185 +0000 utc 
-Deletedsha256:e486d081a2821af119adbc458214cacf510ebb519cdf31e04ac3d4c6ac521c31 +Status
-Deleted: sha256:d206757aba612d90965729f186dfb70aa5e63b53dafd7e7b20a76005acddfe24 + State:         Ready 
-Deletedsha256:1b953394add763fbaa50446b03d636f453fa75b2d12676ceb4b71681b4da6e7d + Availability        Active 
-Deletedsha256:e8a2cacb793cb843e35bbf64e9c73d685d83ecc8192fbdbc098b0e5fbcced848 + Address:         192.168.99.101 
-Deletedsha256:19eec9bf8dcc3cb15b93cdcff717057444c540ee641cf20b7ef647d19b9d1df4 +Platform
-Deletedsha256:2fb6f2d834e4dd55a7a6bb1472f5c293242e6439982332143d7332642a238d40 + Operating System:     linux 
-Deletedsha256:e08b039d73e73f17b3fa02ebf9a28ef156a7b43b828cd67ed422b9d7a01e5482 + Architecture:     x86_64 
-Deletedsha256:bd85e070a996530cc5f576bc5f56a0e3a159e00091410987416844de6e018415 +Resources
-Deleted: sha256:6269effe5aa88dfc0071a2841605d95c0d809111333b5044b2459b43e5879f44 + CPUs:         1 
-Deletedsha256:784ff50f126370cb3be928cd14a078605990efda458e73ad43f2a2e40e1efda2 + Memory:         995.8MiB 
-Deletedsha256:29efd197b6056e252ebb46fe1b315489c2f8e032eb32d1f6fcd0119ee9536df7 +Plugins
-Deletedsha256:3d42e373d713bfab9403159f282ba4cfaa7b4f33e57d5e36d4d2ca0ca1a2f4e7 + Log:         awslogs, fluentd, gcplogs, gelf, journald, json-file, logentries, splunk, syslog 
-Deleted: sha256:518c6772b2fc316c63e9f4f9745e3587f169ec916fd26749b0ce7bf1f36bb93b + Network:         bridge, host, macvlan, null, overlay 
-Deletedsha256:e74bff63859c2597691fffd6fe95b35b0803f6791bc6565072bf07067574dba3 + Volume:         local 
-Deletedsha256:f76baad394e6d835fa0e166254e9f70af873fe43232c67ac198a67865084ccee +Engine Version:     17.06.2-ce 
-Deletedsha256:b0eba742532f664bab6fc6d5bd00c60141397ba299f6743457f7ead64d7c714d +Engine Labels
-Deletedsha256:c10c49233bc62ce69aafa1a44a62d8639a7be08d68b1c23d6b25ebb13e5324b0 + - provider=virtualbox 
-Deleted: sha256:1c8e9ba14469736fa03ede127e47f5821ca97b3029385ec1348e87932c875ff8 +TLS Info
-Deletedsha256:611f5c9e21fce8d870f9ba82248980ca3baaaf95afef2b17504372d1ca03cb5a + TrustRoot
-Deletedsha256:4cb1abe123254326dba72305ef897fdf5364ebb1823413e13dbced41990f951e +-----BEGIN CERTIFICATE----- 
-Deleted: sha256:e10e5ea91f007db418b284f4adc5f0b98f374d79ae52b9687b0d6d33865ffbcf +MIIBajCCARCgAwIBAgIUNuU4I89kxId2QXulofRKxJa9XRcwCgYIKoZIzj0EAwIw 
-Deleted: sha256:c69ae1aa46985cbaf186b6354c61a1d2e0d6af47133db47bf04f0c6eb9c858e9+EzERMA8GA1UEAxMIc3dhcm0tY2EwHhcNMTcwOTA4MTEzOTAwWhcNMzcwOTAzMTEz 
 +OTAwWjATMREwDwYDVQQDEwhzd2FybS1jYTBZMBMGByqGSM49AgEGCCqGSM49AwEH 
 +A0IABEqgLUbyjyNuP35aAzW+aqVB8AkghvpF5hq1KnMveHbl4Ilr+EyDjlYZkbnt 
 +Gb/xmsy/tOP8uz598ZX/JlR4fZyjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMB 
 +Af8EBTADAQH/MB0GA1UdDgQWBBSzoKGrN0ELfEIMsjxuYj5LAckD2jAKBggqhkjO 
 +PQQDAgNIADBFAiB34DOvDtIYjJ+GzbPMGu9Dd/cJGvy7CJg1tNUG3SoOrAIhAJZ4 
 +TJBucTomFSDsj5Y/R6TfhcpXpsksk7JwYgEglu44 
 +-----END CERTIFICATE-----
  
-root@debian9:~# docker images + Issuer Subject: MBMxETAPBgNVBAMTCHN3YXJtLWNh 
-REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE + Issuer Public Key: MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAESqAtRvKPI24/floDNb5qpUHwCSCG+kXmGrUqcy94duXgiWv4TIOOVhmRue0Zv/GazL+04/y7Pn3xlf8mVHh9nA==
-i2tch/mydocker          latest              c37edbd43993        5 hours ago         193MB +
-localhost:88/mydocker   latest              c37edbd43993        5 hours ago         193MB+
 </code> </code>
  
-Renommez l'image **i2tch/mydocker** afin de pointer vers le serveur de registre :+====3.9 - Haute Disponibilité==== 
 + 
 +Quand un nœud est actif, il est capable de recevoir de nouvelles tâches à partir du manager : 
 + 
 +  pendant un scale-up, 
 +  pendant une une mise à jour progressive, 
 +  quand un autre nœud reçois une instruction de se mettre en indisponibilité, 
 +  * quand un service se mets en échec sur un autre nœud  
 + 
 +Rappelez-vous que la swarm contient 6 VM Docker :
  
 <code> <code>
-root@debian9:~# docker tag i2tch/mydocker myregistry:5000/mydocker +docker@manager1:~docker node ls                                                                                                                                                                             
-root@debian9:~docker images +ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION 
-REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE +y0war0lijmwhnexrfhfflulsd *   manager1            Ready               Active              Leader              19.03.12 
-i2tch/mydocker             latest              c37edbd43993        5 hours ago         193MB +v5ai62lmhfsdcauccqmjyu6qk     worker1             Ready               Active                                  19.03.12 
-localhost:88/mydocker      latest              c37edbd43993        5 hours ago         193MB +j4mr3d2ji30t7hu0trob5dpgz     worker2             Ready               Active                                  19.03.12 
-myregistry:5000/mydocker   latest              c37edbd43993        5 hours ago         193MB+pouo7nuvirq0qkuvvrp04a47h     worker3             Ready               Active                                  19.03.12 
 +mo0dd5ech6ifdgd8pa6cjz896     worker4             Ready               Active                                  19.03.12 
 +5am2vd39pybytu1nd3oooabtq     worker5             Ready               Active                                  19.03.12
 </code> </code>
  
-Pour Trainee10 à Trainee19éditez le fichier **/etc/hosts** afin de pointer le 10.0.2.61 vers le nom **myregistry** :+et que sur les 6 VM Docker, il y a 8 conteneurs,
  
 <code> <code>
-root@debian9:~# vi /etc/hosts +docker@manager1:~$ docker service ps web                                                                                                                                                                      
-root@debian9:~# cat /etc/hosts +ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE            ERROR               PORTS 
-127.0.0.1 localhost +son0vgc73drb        web.1               nginx:latest        worker4             Running             Running 12 minutes ago                        
-10.0.2.60 debian9.i2tch.loc debian9 +ojqyweuo65jw        web.2               nginx:latest        worker5             Running             Running 12 minutes ago                        
-10.0.2.61 myregistry.i2tch.loc    myregistry +mb40onnaxd0u        web.3               nginx:latest        manager1            Running             Running 12 minutes ago                        
-10.0.2.62 manager.i2tch.loc manager +4vwsho5x7i36        web.4               nginx:latest        worker2             Running             Running 12 minutes ago                        
-10.0.2.63 worker1.i2tch.loc worker1 +sk9hr6j2u47c        web.5               nginx:latest        worker3             Running             Running 12 minutes ago                        
-10.0.2.64 worker2.i2tch.loc worker2 +pui4dnkepu27        web.6               nginx:latest        worker1             Running             Running 4 minutes ago                         
- +yj0kexdcuo5u        web.7               nginx:latest        worker5             Running             Running 4 minutes ago                         
-# The following lines are desirable for IPv6 capable hosts +93jtbxqj2dyz        web.8               nginx:latest        worker1             Running             Running 4 minutes ago   
-::1     localhost ip6-localhost ip6-loopback +
-ff02::1 ip6-allnodes +
-ff02::2 ip6-allrouters+
 </code> </code>
  
-Pour Trainee20 à Trainee29, éditez le fichier **/etc/hosts** afin de pointer le 10.0.2.41 vers le nom **myregistry** :+dont deux se trouvent sur worker1 :
  
 <code> <code>
-root@debian9:~# vi /etc/hosts +docker@manager1:~$ docker node ps worker1                                                                                                                                                                     
-root@debian9:~# cat /etc/hosts +ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE           ERROR               PORTS 
-127.0.0.1 localhost +pui4dnkepu27        web.6               nginx:latest        worker1             Running             Running 4 minutes ago                        
-10.0.2.40 debian9.i2tch.loc debian9 +93jtbxqj2dyz        web.8               nginx:latest        worker1             Running             Running 4 minutes ago     
-10.0.2.41 myregistry.i2tch.loc    myregistry +</code>
-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'indisponibilité en utilisant l'option **--availability drain** : 
-::1     localhost ip6-localhost ip6-loopback + 
-ff02::1 ip6-allnodes +<code> 
-ff02::2 ip6-allrouters+docker@manager1:~$ docker node update --availability drain worker1                                                                                                                                            
 +worker1
 </code> </code>
  
-Déplacez le fichier **/tmp/ca.crt** vers le répertoire **/etc/docker/certs.d/myregistry:5000/** :+Constatez que le service web a été déplacé sur deux autres noeuds, **manager1** et **worker4** :
  
 <code> <code>
-root@debian9:~# mkdir -p /etc/docker/certs.d/myregistry:5000 +docker@manager1:~docker service ps web                                                                                                                                                                      
-root@debian9:~# mv /tmp/ca.crt /etc/docker/certs.d/myregistry:5000/+ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE            ERROR               PORTS 
 +son0vgc73drb        web.1               nginx:latest        worker4             Running             Running 14 minutes ago                        
 +ojqyweuo65jw        web.2               nginx:latest        worker5             Running             Running 14 minutes ago                        
 +mb40onnaxd0u        web.3               nginx:latest        manager1            Running             Running 14 minutes ago                        
 +4vwsho5x7i36        web.4               nginx:latest        worker2             Running             Running 14 minutes ago                        
 +sk9hr6j2u47c        web.5               nginx:latest        worker3             Running             Running 14 minutes ago                        
 +ag41oh489h4t        web.6               nginx:latest        manager1            Running             Running 3 seconds ago                         
 +pui4dnkepu27         \_ web.6           nginx:latest        worker1             Shutdown            Shutdown 4 seconds ago                        
 +yj0kexdcuo5u        web.7               nginx:latest        worker5             Running             Running 5 minutes ago                         
 +kv7ax6cwzpkf        web.8               nginx:latest        worker2             Running             Running 3 seconds ago                         
 +93jtbxqj2dyz         \_ web.8           nginx:latest        worker1             Shutdown            Shutdown 4 seconds ago  
 </code> </code>
  
-Testez la réponse du registre :+====3.10 - Supprimer un Service=== 
 + 
 +Pour supprimer un service il convient d'utiliser la commande **docker service rm**
  
 <code> <code>
-root@debian9:~# curl http://myregistry:5000/v2/ +docker@manager1:~$ docker service rm web                                                                                                                                                                      
-+web 
 + 
 +docker@manager1:~$ docker service ls                                                                                                                                                                          
 +ID                  NAME                MODE                REPLICAS            IMAGE               PORTS 
 + 
 +docker@manager1:~$ docker service inspect web                                                                                                                                                                 
 +[] 
 +Status: Error: no such service: web, Code: 1
 </code> </code>
  
-Finalement, envoyez l'image au registre :+====3.11 - Sauvegarder Docker Swarm==== 
 + 
 +La configuration de Docker Swarm est contenue dans le répertoire **/var/lib/docker/swarm** de chaque Manager dans le Swarm :
  
 <code> <code>
-root@debian9:~# docker push myregistry:5000/mydocker +docker@manager1:~$ sudo su -  
-The push refers to a repository [myregistry:5000/mydocker] +                                                                                                                                                                                 
-873a8ac77d4dPushed  +root@manager1:~# ls -l /var/lib/docker/swarm                                                                                                                                                                  
-b362758f4793Pushed  +total 20 
-latestdigest: sha256:30866da81d92d2a1015b869c596ddd6e188f33894c41d8effa2161e5c2862b1f size5531+drwxr-xr-x    2 root     root          4096 Dec 16 13:38 certificates 
 +-rw-------    1 root     root           215 Dec 16 13:38 docker-state.json 
 +drwx------    4 root     root          4096 Dec 16 13:38 raft 
 +-rw-------    1 root     root            70 Dec 16 13:38 state.json 
 +drwxr-xr-x    2 root     root          4096 Dec 16 13:38 worker
 </code> </code>
 +
 +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 **/var/lib/docker/swarm**,
 +  * 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 **/var/lib/docker/swarm** dans le nouveau Manager,
 +  * restauration du répertoire **/var/lib/docker/swarm** dans le nouveau Manager à partir de la sauvegarde,
 +  * exécution de la commande **docker swarm init --force-new-cluster** sur le nouveau Manager,
 +  * ajout des Managers et Workers à Swarm.
  
 ----- -----
-<html> + 
-<div align="center"> +Copyright © 2024 Hugh Norris.
-Copyright © 2021 Hugh NORRIS +
-</div> +
-</html>+
Menu