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:drf05 [2021/11/21 11:42] – created adminelearning:workbooks:docker3:drf05 [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~~
  
-======DOF606 - Docker Compose, Docker Machine et Docker Swarm======+======DOF606 - Gestion du Réseau Overlay avec Docker en mode Swarm======
  
 =====Contenu du Module===== =====Contenu du Module=====
  
-  * **DOF606 - Docker Compose, Docker Machine et Docker Swarm**+  * **DOF606 - Gestion du Réseau Overlay avec Docker en mode Swarm**
     * Contenu du Module     * Contenu du Module
-    * LAB #1 - Docker Compose +    * L'Approche Réseau Docker 
-      * 1.1 - Installation +    * LAB #Gestion du Réseau overlay 
-      * 1.2 - Utiliser docker-compose +      * 1.1 - Création d'un Réseau overlay 
-    * LAB #Docker Machine +      * 1.2 - Création d'un Service 
-      * 2.1 - Présentation +      * 1.3 - Déplacer le Service vers un autre Réseau overlay 
-      * 2.2 - Création de Machines Virtuelles Docker +      * 1.4 - DNS container discovery 
-      * 2.3 - Lister les VM Docker +      * 1.5 - Création d'un Réseau overlay Personnalisé 
-      * 2.4 - Obtenir l'adresse IP des VM +    * LAB #2 - Gestion de l'Architecture des Microservices 
-      * 2.5 - Se connecter à une VM Docker +      * 2.Mise en Place avec Docker Swarm avec des réseaux Overlay
-    * LAB #3 - Docker Swarm +
-      * 3.1 - Présentation +
-      * 3.2 - Initialiser Docker Swarm +
-      * 3.3 - Le Statut Leader +
-      * 3.4 - Rejoindre le Swarm +
-      * 3.5 - Consulter les Informations 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.Haute Disponibilité +
-      * 3.10 - Supprimer un Service +
-      * 3.11 - Sauvegarder Docker Swarm +
-      * 3.12 - Restaurer Docker Swarm+
  
-=====LAB #1 - Docker Compose=====+=====L'Approche Réseau 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 logicielle. Son 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**.+L'approche réseau de Docker est **libnetwork** qui implémente le **C**ontainer **N**etwork **M**odel (CNM)Dans ce modèle on trouve trois composants :
  
-Ce fichierappelé par la commande **docker-compose build** commence avec un mot clef **image** ou **build** selon que l'image est récupérée sur un registre ou provient du répertoire cité dans le fichier. Le reste du fichier contient des instructions pour définir la compilation des images constituantes, pour lier des conteneurs et pour définir l'environnement.+  * Sandbox, 
 +    * contient la configuration réseau du conteneur à savoir, la gestion des interfaces, la table de routage et le DNS, 
 +  Endpoint, 
 +    relie un sandbox à un network, 
 +  Network, 
 +    * un groupe d'endpoints qui communiquent directement.
  
-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**.+{{ :elearning:workbooks:docker:docker-3.jpg?direct&600 |image}}
  
-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**.+=====LAB #1 Gestion du Réseau overlay=====
  
-====1.Installation====+En plus des réseaux **bridge**, **host** et **none**, Docker propose deux autres types de réseaux, à savoir **overlay** et **macvlan**Ce module concerne overlay. Pour plus d'informations concernant le type **macvlan**, consultez le site de la documentation de Docker **[[https://docs.docker.com/network/network-tutorial-macvlan/|ici]]**.
  
-Récupérez docker-compose avec **curl** :+Comme son nom indique, un réseau overlay est un réseau qui se positionne au-dessus du réseau des hôtes. Lors de la création d'un réseau overlay, celui-ci n'est disponible par défaut qu'aux services swarm. Par contre il est possible de connecter des conteneurs autonomes au réseau overlay si l'option **--attachable** est spécifiée lors de sa création. Ce type d'utilisation du réseau overlay n'est pas recommandé par Docker qui dit que le support de cette fonctionnalité pourrait être retiré. 
 +  
 +Le trafic lié à la gestion des services swarm est crypté par défaut avec l’algorithme AES en mode GCM. Afin de crypter le trafic des données liées aux applications il est possible d'utiliser l'option **--opt encrypted** lors de la création du réseau overlay. Dans ce cas, Docker crée des tunnels IPSEC entre chaque nœud qui utilise le même algorithme que le trafic des services swarm. Il y a donc une dégradation des performances à évaluer avant la mise en production. Dans les deux cas les clefs sont modifiées toutes les 12 heures (voir [[https://www.vaultproject.io/docs/internals/rotation.html]])
  
-<code+<WRAP center round important 50%
-root@debian9:~# curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose +**ATTENTION** Le cryptage des données liées aux applications n'est pas compatible avec Windows(tm). Lors de la connexion du nœud Windows(tmà un réseau overlay crypté, aucune erreur ne sera rapportée. Par contre le nœud sera incapable de communiquer. 
-  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current +</WRAP>
-                                 Dload  Upload   Total   Spent    Left  Speed +
-100   617    0   617    0        912      0 --:--:-- --:--:-- --:--:--   912 +
-100 5140k  100 5140k    0      2145k      0  0:00:02  0:00:02 --:--:-- 5232k+
  
-root@debian9:~# chmod +x /usr/local/bin/docker-compose  +Commencez par re-créer un swarm en utilisant les machines virtuelles **manager**, **worker1** et **worker2** :
-</code> +
- +
-Rendez **/usr/local/bin/docker-compose** exécutable :+
  
 <code> <code>
-root@debian9:~# ls -l /usr/local/bin/docker-compose  +root@debian11:~# ssh -l trainee 10.0.2.62 
--rw-r--r-- 1 root staff 5263681 Jan  16:29 /usr/local/bin/docker-compose +The authenticity of host '10.0.2.62 (10.0.2.62)' can't be established. 
-root@debian9:~chmod u+x /usr/local/bin/docker-compose  +ECDSA key fingerprint is SHA256:sEfHBv9azmK60cjqF/aJgUc9jg56slNaZQdAUcvBOvE. 
-</code>+Are you sure you want to continue connecting (yes/no/[fingerprint])? yes 
 +Warning: Permanently added '10.0.2.62' (ECDSA) to the list of known hosts. 
 +trainee@10.0.2.62's passwordtrainee 
 +Linux manager.i2tch.loc 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64
  
-Avant de commencer, installez l'utilitaire **tree** :+The programs included with the Debian GNU/Linux system are free software; 
 +the exact distribution terms for each program are described in the 
 +individual files in /usr/share/doc/*/copyright.
  
-<code> +Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent 
-root@debian9:~# apt-get install tree +permitted by applicable law
-Reading package lists... Done +Last loginSun Jul 17 08:27:29 2022 from 10.0.2.1 
-Building dependency tree        +trainee@manager:~$ su 
-Reading state information... Done +Mot de passe : fenestros 
-The following NEW packages will be installed: +root@manager:~#
-  tree +
-0 upgraded1 newly installed, 0 to remove and 99 not upgraded. +
-Need to get 45.9 kB of archives. +
-After this operation, 102 kB of additional disk space will be used+
-Get:1 http://ftp.fr.debian.org/debian/ jessie/main tree amd64 1.7.0-3 [45.9 kB] +
-Fetched 45.9 kB in 0s (429 kB/s) +
-Selecting previously unselected package tree. +
-(Reading database ... 100654 files and directories currently installed.) +
-Preparing to unpack .../tree_1.7.0-3_amd64.deb ... +
-Unpacking tree (1.7.0-3) ... +
-Processing triggers for man-db (2.7.0.2-5) ... +
-Setting up tree (1.7.0-3) ... +
-</code>+
  
-====1.2 - Utiliser docker-compose====+root@manager:~# docker swarm leave 
 +Node left the swarm. 
 +root@manager:~# docker swarm init --advertise-addr 10.0.2.62 
 +Swarm initialized: current node (tpn1zsk20sfsfafmk2cvefqjc) is now a manager.
  
-===Une Application Simple===+To add a worker to this swarm, run the following command:
  
-Dans ce LAB vous allez créer une application simple ayant deux environnements différents :+    docker swarm join --token SWMTKN-1-23d7n1fkkk9rvlhty106q9390bfpf9daljjguq3s807le6c5qs-e0s1yqsajvmi7s8t9l9mw48ao 10.0.2.62:2377
  
-  * development +To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions
-  * production +root@manager:~# exit 
- +trainee@manager:~# exit
-afin d'utiliser deux configurations différentes selon l'environnement désiré. +
- +
-Commencez par créer l'arborescence du projet : +
- +
-<code> +
-root@debian9:~# mkdir -p MyApp/common +
-root@debian9:~# mkdir -p MyApp/development/content +
-root@debian9:~# mkdir -p MyApp/production/content +
-root@debian9:~# touch MyApp/common/docker-compose.yml MyApp/development/docker-compose.yml MyApp/production/docker-compose.yml +
-root@debian9:~# touch MyApp/production/content/Dockerfile MyApp/production/content/index.html +
-root@debian9:~# touch MyApp/development/content/Dockerfile MyApp/development/content/index.html+
 </code> </code>
  
-Utilisez l'utilitaire tree pour visualiser la structure du projet :+Connectez-vous au **worker1** :
  
 <code> <code>
-root@debian9:~# cd MyApp +root@manager:~# ssh -l trainee 10.0.2.63 
-root@debian9:~/MyApp# tree +The authenticity of host '10.0.2.63 (10.0.2.63)' can't be established. 
-+ECDSA key fingerprint is SHA256:sEfHBv9azmK60cjqF/aJgUc9jg56slNaZQdAUcvBOvE
-├── common +Are you sure you want to continue connecting (yes/no)? yes 
-│   └── docker-compose.yml +Warning: Permanently added '10.0.2.63' (ECDSA) to the list of known hosts
-├── development +trainee@10.0.2.63's password: trainee 
-│   ├── content +Linux worker1.i2tch.loc 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64
-│   │   ├── Dockerfile +
-│   │   └── index.html +
-│   └── docker-compose.yml +
-└── production +
-    ├── content +
-    │   ├── Dockerfile +
-    │   └── index.html +
-    └── docker-compose.yml+
  
-5 directories, 7 files +The programs included with the Debian GNU/Linux system are free software; 
-</code>+the exact distribution terms for each program are described in the 
 +individual files in /usr/share/doc/*/copyright.
  
-Ce projet comporte la structure suivante :+Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent 
 +permitted by applicable law. 
 +Last loginSun Mar 21 16:34:26 2021 from 10.0.2.11 
 +trainee@worker1:~$ su - 
 +Mot de passe : fenestros 
 +root@worker1:~#
  
-  * **common** +root@worker1:~# docker swarm leave 
-    * La configuration commune aux deux environnements sera placée dans le fichier **MyApp/common/docker-compose.yml**. +Node left the swarm.
-  * **development** +
-    * La configuration spécifique à l'environnement **development** sera placée dans le fichier **MyApp/development/docker-compose.yml**. Le contenu du fichier **index.html** sera **This is the development environement**.  +
-  * **production** +
-    * La configuration spécifique à l'environnement **production** sera placée dans le fichier **MyApp/production/docker-compose.yml**. Le contenu du fichier **index.html** sera **This is the production environment**.+
  
-Commencez par la création des deux Dockerfile pour **development** et **production**. Afin de garder l'exemple le plus simple que possible, ces deux fichiers sont identiques : +root@worker1:~# docker swarm join --token SWMTKN-1-23d7n1fkkk9rvlhty106q9390bfpf9daljjguq3s807le6c5qs-e0s1yqsajvmi7s8t9l9mw48ao 10.0.2.62:2377 
- +This node joined a swarm as a worker.
-<code> +
-root@debian9:~/MyAppvi development/content/Dockerfile +
  
-root@debian9:~/MyAppcat development/content/Dockerfile  +root@worker1:~# exit 
-FROM tianon/true+déconnexion
  
-VOLUME ["/usr/share/nginx/html/" +trainee@worker1:~$ exit 
-ADD index.html /usr/share/nginx/html/+déconnexion 
 +Connection to 10.0.2.63 closed.
  
-root@debian9:~/MyAppcp development/content/Dockerfile production/content/Dockerfile +root@manager:~# 
 </code> </code>
  
-Créez maintenant le fichier **MyApp/common/docker-compose.yml** :+Connectez-vous au **worker2** :
  
 <code> <code>
-root@debian9:~/MyAppvi common/docker-compose.yml+root@manager:~# ssh -l trainee 10.0.2.64 
 +The authenticity of host '10.0.2.64 (10.0.2.64)' can't be established. 
 +ECDSA key fingerprint is SHA256:sEfHBv9azmK60cjqF/aJgUc9jg56slNaZQdAUcvBOvE. 
 +Are you sure you want to continue connecting (yes/no)? yes 
 +Warning: Permanently added '10.0.2.64' (ECDSA) to the list of known hosts. 
 +trainee@10.0.2.64's password: trainee 
 +Linux worker2.i2tch.loc 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64
  
-root@debian9:~/MyApp# cat common/docker-compose.yml +The programs included with the Debian GNU/Linux system are free software; 
-web:  +the exact distribution terms for each program are described in the 
-  image: nginx  +individual files in /usr/share/doc/*/copyright.
-  ports:  +
-    - 8082:80 +
-</code>+
  
-Les deux fichiers **MyApp/development/docker-compose.yml** et **MyApp/production/docker-compose.yml** sont identiques :+Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent 
 +permitted by applicable law. 
 +Last login: Sun Mar 21 16:18:25 2021 from 10.0.2.11 
 +trainee@worker2:~$ su - 
 +Mot de passe : fenestros 
 +root@worker2:~# 
  
-<code> +root@worker2:~# docker swarm leave 
-root@debian9:~/MyAppvi development/docker-compose.yml +Node left the swarm.
-  +
-root@debian9:~/MyApp# cat development/docker-compose.yml  +
-web:  +
-  extends:  +
-    file: ../common/docker-compose.yml  +
-    service: web  +
-  volumes_from:  +
-    - content+
  
-content:  +root@worker2:~# docker swarm join --token SWMTKN-1-23d7n1fkkk9rvlhty106q9390bfpf9daljjguq3s807le6c5qs-e0s1yqsajvmi7s8t9l9mw48ao 10.0.2.62:2377 
-  build: content +This node joined a swarm as a worker.
- +
-root@debian9:~/MyAppcp development/docker-compose.yml production/docker-compose.yml +
-</code> +
- +
-Éditez maintenant les deux fichiers index.html +
- +
-<code> +
-root@debian9:~/MyApp# vi development/content/index.html+
  
-root@debian9:~/MyAppcat development/content/index.html +root@worker2:~# exit 
-<html> +déconnexion
-<body> +
-<center>This is the development environement</center> +
-</body> +
-</html>+
  
-root@debian9:~/MyApp# vi production/content/index.html+trainee@worker2:~$ exit 
 +déconnexion 
 +Connection to 10.0.2.64 closed.
  
-root@debian9:~/MyAppcat production/content/index.html +root@manager:~# 
-<html> +
-<body> +
-<center>This is the production environement</center> +
-</body> +
-</html>+
 </code> </code>
  
-Placez-vous dans le sous-répertoire **development** et exécutez la commande **docker-compose up -d** :+Vérifiez l'état du swarm :
  
 <code> <code>
-root@debian9:~/MyApp/development# docker-compose up -d +root@manager:~# docker node ls 
-Creating development_content_1... +ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION 
-Building content... +b85hxlixbr1mh1txd1hrfe4us *   manager.i2tch.loc   Ready               Active              Leader              19.03.4 
-Step 1/3 : FROM tianon/true +4sui75vvdhmet4qvt0zbvzlzl     worker1.i2tch.loc   Ready               Active                                  19.03.4 
- ---> 1298b2036003 +lbjtg5o9kw3x6xg7frm07jfuw     worker2.i2tch.loc   Ready               Active                                  19.03.4 
-Step 2/3 VOLUME /usr/share/nginx/html/ +root@manager:~# docker node ls --filter role=manager 
- ---> Running in 8619de833add +ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION 
- ---> 694e4f111996 +b85hxlixbr1mh1txd1hrfe4us *   manager.i2tch.loc   Ready               Active              Leader              19.03.4 
-Removing intermediate container 8619de833add +root@manager:~# docker node ls --filter role=worker 
-Step 3/3 : ADD index.html /usr/share/nginx/html/ +ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION 
- ---> f6fabac6703b +4sui75vvdhmet4qvt0zbvzlzl     worker1.i2tch.loc   Ready               Active                                  19.03.4 
-Removing intermediate container a9bec35dba66 +lbjtg5o9kw3x6xg7frm07jfuw     worker2.i2tch.loc   Ready               Active                                  19.03.4
-Successfully built f6fabac6703b +
-Successfully tagged development_content:latest +
-Creating development_web_1...+
 </code> </code>
  
-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**. +Vérifiez la présence du réseau overlay **ingress** ainsi que le réseau ponté **docker_gwbridge** :
- +
-Les options de la commande **docker-compose** sont :+
  
 <code> <code>
-root@debian9:~# docker-compose --help +root@manager:~# docker network ls 
-Fast, isolated development environments using Docker.+NETWORK ID          NAME                DRIVER              SCOPE 
 +4edb7186dcc9        bridge              bridge              local 
 +d4c9b0c9437a        docker_gwbridge     bridge              local 
 +f3cb3bc3c581        host                host                local 
 +r8htcvc8oxmz        ingress             overlay             swarm 
 +de563e30d473        none                null                local 
 +</code>
  
-Usage: +<WRAP center round info 50%> 
-  docker-compose [options] [COMMAND] [ARGS...] +**Info** Le réseau **docker_gwbridge** relie le réseau **ingress** à l'adaptateur réseau de l'hôte et par conséquent relie le démon Docker aux autres démons Docker qui participent dans swarm
-  docker-compose -h|--help+</WRAP>
  
-Options: +<WRAP center round tip 50%> 
-  --verbose                 Show more output +**Best Practice** Docker recommande l'utilisation de réseaux de type overlay différents pour chaque application ou groupe d'applications
-  --version                 Print version and exit +</WRAP>
-  -f, --file FILE           Specify an alternate compose file (defaultdocker-compose.yml) +
-  -p, --project-name NAME   Specify an alternate project name (default: directory name)+
  
-Commands: +====1.1 Création d'un Réseau overlay====
-  build     Build or rebuild services +
-  help      Get help on a command +
-  kill      Kill containers +
-  logs      View output from containers +
-  port      Print the public port for a port binding +
-  ps        List containers +
-  pull      Pulls service images +
-  rm        Remove stopped containers +
-  run       Run a one-off command +
-  scale     Set number of containers for a service +
-  start     Start services +
-  stop      Stop services +
-  restart   Restart services +
-  up        Create and start containers +
-</code>+
  
-Vérifiez que l'image **development_content** a été créée :+A partir du Manager, créez un réseau de type overlay appelé **nginx-net** :
  
 <code> <code>
-root@debian9:~/MyApp/development# docker images +root@manager:~# docker network create -d overlay nginx-net 
-REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE +j57jhtug4kjxp22ai1y664lqr 
-development_content        latest              f6fabac6703b        19 seconds ago      209B +root@manager:~# docker network ls 
-...+NETWORK ID          NAME                DRIVER              SCOPE 
 +dde514eea83f        bridge              bridge              local 
 +d4c9b0c9437a        docker_gwbridge     bridge              local 
 +f3cb3bc3c581        host                host                local 
 +r8htcvc8oxmz        ingress             overlay             swarm 
 +j57jhtug4kjx        nginx-net           overlay             swarm 
 +de563e30d473        none                null                local
 </code> </code>
  
-Constatez la présence des deux conteneurs **nginx:latest** et **development_content** :+====1.2 - Création d'un Service==== 
 + 
 +Créez un service nginx qui utilise le réseau **nginx-net** :
  
 <code> <code>
-root@debian9:~/MyApp/development# docker ps -+root@manager:~# docker service create --name my-nginx --publish target=80,published=80 --replicas=5 --network nginx-net nginx 
-CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS                           PORTS                  NAMES +fpydgix3e1rc1qum72gvwcb7f 
-6955516dceff        nginx:latest          "nginx -g 'daemon ..."   28 seconds ago      Up 27 seconds                    0.0.0.0:8082->80/tcp   development_web_1 +overall progress: 5 out of 5 tasks  
-9a1876d7a145        development_content   "/true"                  28 seconds ago      Exited (0) 27 seconds ago                               development_content_1 +1/5: running   [==================================================>]  
-...+2/5running   [==================================================>]  
 +3/5: running   [==================================================> 
 +4/5: running   [==================================================>]  
 +5/5: running   [==================================================> 
 +verify: Service converged 
 </code> </code>
  
-Utilisez maintenant lynx pour consultez **http://localhost:8082** : +<WRAP center round info 50%> 
- +**Info** : Le service publie le port 80 qui est visible de l'extérieur. Les conteneurs communiquent entre eux sans ouvrir de ports supplémentaires. 
-<code> +</WRAP>
-root@debian9:~/MyApp/development# lynx --dump http://localhost:8082 +
-                    This is the development environement+
  
 +Vérifiez que le service fonctionne avant de poursuivre :
  
-root@debian9:~/MyApp/development# +<code> 
 +root@manager:~# docker service ls 
 +ID                  NAME                MODE                REPLICAS            IMAGE               PORTS 
 +fpydgix3e1rc        my-nginx            replicated          5/5                 nginx:latest        *:80->80/tcp
 </code> </code>
  
-Arrêtez docker-compose :+Consultez maintenant les détails du service :
  
 <code> <code>
-root@debian9:~/MyApp/development# docker-compose stop  +root@manager:~# docker service inspect my-nginx 
-Stopping development_web_1... +[ 
-root@debian9:~/MyApp/development# docker ps -a +    { 
-CONTAINER ID        IMAGE                 COMMAND                  CREATED              STATUS                           PORTS               NAMES +        "ID": "fpydgix3e1rc1qum72gvwcb7f", 
-6955516dceff        nginx:latest          "nginx -g 'daemon ..."   About a minute ago   Exited (0seconds ago                             development_web_1 +        "Version":
-9a1876d7a145        development_content   "/true                 About a minute ago   Exited (0) About a minute ago                        development_content_1 +            "Index": 40 
-...+        }, 
 +        "CreatedAt": "2019-10-28T06:23:29.17883246Z", 
 +        "UpdatedAt": "2019-10-28T06:23:29.183438696Z"
 +        "Spec":
 +            "Name": "my-nginx", 
 +            "Labels": {}, 
 +            "TaskTemplate":
 +                "ContainerSpec":
 +                    "Image": "nginx:latest@sha256:922c815aa4df050d4df476e92daed4231f466acc8ee90e0e774951b0fd7195a4", 
 +                    "Init": false, 
 +                    "StopGracePeriod": 10000000000, 
 +                    "DNSConfig": {}, 
 +                    "Isolation": "default" 
 +                }, 
 +                "Resources":
 +                    "Limits": {}, 
 +                    "Reservations": {} 
 +                }, 
 +                "RestartPolicy":
 +                    "Condition": "any", 
 +                    "Delay": 5000000000, 
 +                    "MaxAttempts": 0 
 +                }, 
 +                "Placement":
 +                    "Platforms":
 +                        { 
 +                            "Architecture": "amd64", 
 +                            "OS": "linux" 
 +                        }, 
 +                        { 
 +                            "OS": "linux" 
 +                        }, 
 +                        { 
 +                            "Architecture": "arm64", 
 +                            "OS": "linux" 
 +                        }, 
 +                        { 
 +                            "Architecture": "386", 
 +                            "OS": "linux" 
 +                        }, 
 +                        { 
 +                            "Architecture": "ppc64le", 
 +                            "OS": "linux" 
 +                        }, 
 +                        { 
 +                            "Architecture": "s390x", 
 +                            "OS": "linux" 
 +                        } 
 +                    ] 
 +                }, 
 +                "Networks":
 +                    { 
 +                        "Target": "j57jhtug4kjxp22ai1y664lqr" 
 +                    } 
 +                ], 
 +                "ForceUpdate": 0, 
 +                "Runtime": "container" 
 +            }, 
 +            "Mode":
 +                "Replicated":
 +                    "Replicas": 
 +                } 
 +            }, 
 +            "UpdateConfig": { 
 +                "Parallelism": 1, 
 +                "FailureAction": "pause", 
 +                "Monitor": 5000000000, 
 +                "MaxFailureRatio": 0
 +                "Order": "stop-first" 
 +            }, 
 +            "RollbackConfig":
 +                "Parallelism": 1, 
 +                "FailureAction": "pause", 
 +                "Monitor": 5000000000, 
 +                "MaxFailureRatio": 0, 
 +                "Order": "stop-first" 
 +            }, 
 +            "EndpointSpec":
 +                "Mode": "vip", 
 +                "Ports":
 +                    { 
 +                        "Protocol": "tcp", 
 +                        "TargetPort": 80, 
 +                        "PublishedPort": 80, 
 +                        "PublishMode": "ingress" 
 +                    } 
 +                ] 
 +            } 
 +        }, 
 +        "Endpoint":
 +            "Spec":
 +                "Mode": "vip", 
 +                "Ports":
 +                    { 
 +                        "Protocol": "tcp", 
 +                        "TargetPort": 80, 
 +                        "PublishedPort": 80, 
 +                        "PublishMode": "ingress" 
 +                    } 
 +                ] 
 +            }, 
 +            "Ports":
 +                { 
 +                    "Protocol": "tcp", 
 +                    "TargetPort": 80, 
 +                    "PublishedPort": 80, 
 +                    "PublishMode": "ingress" 
 +                } 
 +            ], 
 +            "VirtualIPs":
 +                { 
 +                    "NetworkID": "r8htcvc8oxmzy896xvwvv87k5", 
 +                    "Addr": "10.255.0.5/16" 
 +                }, 
 +                { 
 +                    "NetworkID": "j57jhtug4kjxp22ai1y664lqr", 
 +                    "Addr": "10.0.0.2/24" 
 +                } 
 +            ] 
 +        } 
 +    } 
 +]
 </code> </code>
  
-Placez-vous maintenant dans le sous-répertoire **production** et exécutez de nouveau la commande **docker-compose up -d** :+<WRAP center round important 50%> 
 +**Important** : Notez ici les informations concernant les ports et les Endpoints utilisés par le service. 
 +</WRAP>
  
-<code> +====1.3 - Déplacer le Service vers un autre Réseau overlay====
-root@debian9:~/MyApp/development# cd ../production/ +
-root@debian9:~/MyApp/production# docker-compose up -d +
-Creating production_content_1... +
-Building content... +
-Step 1/: FROM tianon/true +
- ---> 1298b2036003 +
-Step 2/3 : VOLUME /usr/share/nginx/html/ +
- ---> Using cache +
- ---> 694e4f111996 +
-Step 3/3 : ADD index.html /usr/share/nginx/html/ +
- ---> 61bcd73aff6e +
-Removing intermediate container 18af8bcb48ce +
-Successfully built 61bcd73aff6e +
-Successfully tagged production_content:latest +
-Creating production_web_1... +
-</code>+
  
-Notez la création du conteneur **production_content** :+Consultez le réseau overlay **nginx-net** sur les trois nœuds :
  
 <code> <code>
-root@debian9:~/MyApp/production# docker ps -a +root@manager:~# docker inspect nginx-net 
-CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS                          PORTS                  NAMES +
-8a2c7346a5db        nginx:latest          "nginx -g 'daemon ..."   4 seconds ago       Up 3 seconds                    0.0.0.0:8082->80/tcp   production_web_1 +    { 
-5fde5e7cbd47        production_content    "/true                 seconds ago       Exited (0) 3 seconds ago                               production_content_1 +        "Name": "nginx-net", 
-6955516dceff        nginx:latest          "nginx -g 'daemon ..."   2 minutes ago       Exited (0) About a minute ago                          development_web_1 +        "Id": "j57jhtug4kjxp22ai1y664lqr", 
-9a1876d7a145        development_content   "/true                 minutes ago       Exited (0minutes ago                               development_content_1 +        "Created": "2019-10-28T07:23:29.492986337+01:00"
-...+        "Scope": "swarm", 
 +        "Driver": "overlay", 
 +        "EnableIPv6": false, 
 +        "IPAM":
 +            "Driver": "default", 
 +            "Options": null, 
 +            "Config":
 +                { 
 +                    "Subnet": "10.0.0.0/24", 
 +                    "Gateway": "10.0.0.1" 
 +                } 
 +            ] 
 +        }, 
 +        "Internal"false, 
 +        "Attachable": false, 
 +        "Ingress": false, 
 +        "ConfigFrom":
 +            "Network": "" 
 +        }, 
 +        "ConfigOnly": false, 
 +        "Containers":
 +            "b2e882e530b10f8fd0b2481f851007f864ce1495bc9fdedcf51a475c0fc03aeb":
 +                "Name": "my-nginx.2.bo4q3us1f6m0uwxhqgtau1yg5", 
 +                "EndpointID": "f6f82bcb81ba82191f3988702b0e91f7f5f139c5c88899ad7c95e12ab189e055", 
 +                "MacAddress": "02:42:0a:00:00:04", 
 +                "IPv4Address": "10.0.0.4/24"
 +                "IPv6Address": "" 
 +            }, 
 +            "c0a76b54dad58b0faf80d2f915a10072aa7d726c46036caa3157d22c30dba843":
 +                "Name": "my-nginx.4.aqj5vafpqtkc8f4rn4v04x4kn", 
 +                "EndpointID": "813bef65edc4de42d5ec4357013f5b711cd21ce7d1a1c8361c1d989d0d709071", 
 +                "MacAddress": "02:42:0a:00:00:06", 
 +                "IPv4Address": "10.0.0.6/24", 
 +                "IPv6Address": "" 
 +            }, 
 +            "lb-nginx-net": { 
 +                "Name": "nginx-net-endpoint", 
 +                "EndpointID": "d087f5fe91481b12ca0b966d01584d143b25c746952bb517441cfad6beba90de", 
 +                "MacAddress": "02:42:0a:00:00:08", 
 +                "IPv4Address": "10.0.0.8/24"
 +                "IPv6Address": "" 
 +            } 
 +        }, 
 +        "Options": { 
 +            "com.docker.network.driver.overlay.vxlanid_list": "4097" 
 +        }, 
 +        "Labels": {}, 
 +        "Peers":
 +            { 
 +                "Name": "1199cab4a6dd", 
 +                "IP": "10.0.2.62" 
 +            }, 
 +            { 
 +                "Name": "69676ae46ab9", 
 +                "IP": "10.0.2.63" 
 +            }, 
 +            { 
 +                "Name": "d058d363197d", 
 +                "IP": "10.0.2.64" 
 +            } 
 +        ] 
 +    } 
 +]
 </code> </code>
- 
-En étant dans le contexte **production**, il est possible d'utiliser la commande **docker-compose ps** : 
  
 <code> <code>
-root@debian9:~/MyApp/production# docker-compose ps +root@worker1:~# docker inspect nginx-net 
-        Name                 Command          State           Ports          +
---------------------------------------------------------------------------- +    { 
-production_content_1   /true                  Exit 0                         +        "Name": "nginx-net", 
-production_web_1       nginx -g daemon off;   Up       0.0.0.0:8082->80/tcp +        "Id": "j57jhtug4kjxp22ai1y664lqr", 
 +        "Created": "2019-10-28T07:23:29.561068917+01:00", 
 +        "Scope": "swarm", 
 +        "Driver": "overlay", 
 +        "EnableIPv6": false, 
 +        "IPAM":
 +            "Driver": "default", 
 +            "Options": null, 
 +            "Config":
 +                { 
 +                    "Subnet": "10.0.0.0/24", 
 +                    "Gateway": "10.0.0.1" 
 +                } 
 +            ] 
 +        }, 
 +        "Internal": false, 
 +        "Attachable": false, 
 +        "Ingress": false, 
 +        "ConfigFrom":
 +            "Network": "" 
 +        }, 
 +        "ConfigOnly": false, 
 +        "Containers":
 +            "50b205e2ed4ccaaad5adc06c508af235557c89c116c819e367a1d925e9c2b564":
 +                "Name": "my-nginx.1.gcz867ezj0y46tsdgoz8j3jz2", 
 +                "EndpointID": "a48a43da98acef2748f42ffa992ba302863ed3c417fa3289cbd3aed0e33e97fa", 
 +                "MacAddress": "02:42:0a:00:00:03", 
 +                "IPv4Address": "10.0.0.3/24", 
 +                "IPv6Address": "" 
 +            }, 
 +            "lb-nginx-net": { 
 +                "Name": "nginx-net-endpoint", 
 +                "EndpointID": "54ed15511cdd574cb60d37d39257cbf7b30331b24bb069aadb33b457b2864789", 
 +                "MacAddress": "02:42:0a:00:00:0a", 
 +                "IPv4Address": "10.0.0.10/24", 
 +                "IPv6Address": "" 
 +            } 
 +        }, 
 +        "Options":
 +            "com.docker.network.driver.overlay.vxlanid_list": "4097" 
 +        }, 
 +        "Labels": {}, 
 +        "Peers":
 +            { 
 +                "Name": "69676ae46ab9", 
 +                "IP": "10.0.2.63" 
 +            }, 
 +            { 
 +                "Name": "d058d363197d", 
 +                "IP": "10.0.2.64" 
 +            }, 
 +            { 
 +                "Name""1199cab4a6dd", 
 +                "IP": "10.0.2.62" 
 +            } 
 +        ] 
 +    } 
 +]
 </code> </code>
- 
-De même en utilisant la même commande dans le répertoire **development**, on peut constater l'état de l'environnement **development** : 
  
 <code> <code>
-root@debian9:~/MyApp/productioncd ../development/ +root@worker2:~# docker inspect nginx-net 
-root@debian9:~/MyApp/development# docker-compose ps +
-        Name                  Command          State    Ports  +    { 
-------------------------------------------------------------- +        "Name": "nginx-net", 
-development_content_1   /true                  Exit          +        "Id": "j57jhtug4kjxp22ai1y664lqr", 
-development_web_1       nginx -g daemon off;   Exit   +        "Created": "2019-10-28T07:23:29.562818383+01:00", 
 +        "Scope": "swarm", 
 +        "Driver": "overlay", 
 +        "EnableIPv6": false, 
 +        "IPAM":
 +            "Driver": "default", 
 +            "Options": null, 
 +            "Config":
 +                { 
 +                    "Subnet": "10.0.0.0/24", 
 +                    "Gateway""10.0.0.1" 
 +                } 
 +            ] 
 +        }, 
 +        "Internal": false, 
 +        "Attachable": false, 
 +        "Ingress": false, 
 +        "ConfigFrom":
 +            "Network": "" 
 +        }, 
 +        "ConfigOnly": false, 
 +        "Containers":
 +            "31bcb5e553886cd9b3a6b8e70fe0c2bed92fe081bd0def0c94864631a940cbd6":
 +                "Name": "my-nginx.5.t3be85jtp2qlhpmvsl4866s5m", 
 +                "EndpointID": "ffa92f5f3bb7fd2665a8be336ef1e4e2d786790852eb152dac1a2c45f18518ba", 
 +                "MacAddress": "02:42:0a:00:00:07", 
 +                "IPv4Address": "10.0.0.7/24", 
 +                "IPv6Address": "" 
 +            }, 
 +            "8e2ce40a6e0d9fb2bc64c264b92164b6ea241a2369d8e6844d00b8952f5729a7":
 +                "Name": "my-nginx.3.dma616z2rkbted13zd824fyo2", 
 +                "EndpointID": "99cfb31ce34ccd9b6b15f71c87eddb5f39a84512ec76d215d54bdaaf851d5129", 
 +                "MacAddress": "02:42:0a:00:00:05", 
 +                "IPv4Address": "10.0.0.5/24", 
 +                "IPv6Address": "" 
 +            }, 
 +            "lb-nginx-net": { 
 +                "Name": "nginx-net-endpoint", 
 +                "EndpointID": "c0816f6f1e5c046ac1deb8163c5a8cf40765a126bf76b6f10bf1bb708a51dfa1", 
 +                "MacAddress": "02:42:0a:00:00:09", 
 +                "IPv4Address": "10.0.0.9/24", 
 +                "IPv6Address": "" 
 +            } 
 +        }, 
 +        "Options":
 +            "com.docker.network.driver.overlay.vxlanid_list": "4097" 
 +        }, 
 +        "Labels": {}, 
 +        "Peers":
 +            { 
 +                "Name": "d058d363197d", 
 +                "IP": "10.0.2.64" 
 +            }, 
 +            { 
 +                "Name": "69676ae46ab9", 
 +                "IP": "10.0.2.63" 
 +            }, 
 +            { 
 +                "Name": "1199cab4a6dd", 
 +                "IP": "10.0.2.62" 
 +            } 
 +        ] 
 +    } 
 +]
 </code> </code>
  
-Utilisez maintenant lynx pour consultez **http://localhost:8082** :+<WRAP center round important 50%> 
 +**Important** : Notez que le réseau **nginx-net** a été créé automatiquement sur les deux Workers. Notez aussi le contenu de la section **Peers** qui liste les nœuds ainsi que la section **Containers** qui liste les conteneurs sur chaque nœud qui sont connectés au réseau overlay. 
 +</WRAP> 
 + 
 +Créez maintenant un deuxième réseau de type overlay, appelé **nginx-net-2** :
  
 <code> <code>
-root@debian9:~/MyApp/developmentlynx --dump http://localhost:8082 +root@manager:~# docker network create -d overlay nginx-net-2 
-                     This is the production environement+aez5huut9hd472qmldzf2tsud 
 +</code>
  
 +Déplacez le service **my-nginx** vers le réseau **nginx-net-2** : 
  
-root@debian9:~/MyApp/development#+<code> 
 +root@manager:~# docker service update --network-add nginx-net-2 --network-rm nginx-net my-nginx 
 +my-nginx 
 +overall progress: 5 out of 5 tasks  
 +1/5: running   [==================================================>]  
 +2/5: running   [==================================================>]  
 +3/5: running   [==================================================>]  
 +4/5: running   [==================================================>]  
 +5/5: running   [==================================================>]  
 +verify: Service converged 
 </code> </code>
  
-===Installer Wordpress avec Docker Compose=== +Vérifiez que le service fonctionne avant de poursuivre :
- +
-Créez maintenant le répertoire **wordpress1** dans /root :+
  
 <code> <code>
-root@debian9:~/MyApp/developmentcd ~ +root@manager:~# docker service ls 
-root@debian9:~# mkdir wordpress1+ID                  NAME                MODE                REPLICAS            IMAGE               PORTS 
 +fpydgix3e1rc        my-nginx            replicated          5/5                 nginx:latest        *:80->80/tcp
 </code> </code>
  
-Placez-vous dans le répertoire et créer le fichier **docker-compose.yaml**+Vérifiez qu'aucun conteneur se trouve dans le réseau **nginx-net** :
  
 <code> <code>
-root@debian9:~# cd wordpress1 +root@manager:~# docker network inspect nginx-net 
-root@debian9:~/wordpress1# vi docker-compose.yaml +
-root@debian9:~/wordpress1# cat docker-compose.yaml +    { 
-version: "3.3+        "Name""nginx-net", 
-     +        "Id": "j57jhtug4kjxp22ai1y664lqr", 
-services: +        "Created""2019-10-28T06:21:18.337578134Z", 
-  db: +        "Scope""swarm", 
-    imagemysql:5.7 +        "Driver""overlay", 
-    volumes+        "EnableIPv6"false, 
-      - db_data:/var/lib/mysql +        "IPAM"{ 
-    restartalways +            "Driver""default", 
-    environment+            "Options"null, 
-      MYSQL_ROOT_PASSWORDfenestros +            "Config"[ 
-      MYSQL_DATABASEwordpress +                { 
-      MYSQL_USERwordpress +                    "Subnet""10.0.0.0/24", 
-      MYSQL_PASSWORD: wordpress +                    "Gateway""10.0.0.1" 
-     +                } 
-  wordpress+            ] 
-    depends_on+        }, 
-      - db +        "Internal": false, 
-    image: wordpress:latest +        "Attachable"false, 
-    ports: +        "Ingress"false, 
-      "8000:80+        "ConfigFrom"
-    restartalways +            "Network""" 
-    environment+        }, 
-      WORDPRESS_DB_HOSTdb:3306 +        "ConfigOnly"false, 
-      WORDPRESS_DB_USERwordpress +        "Containers"null, 
-      WORDPRESS_DB_PASSWORDwordpress +        "Options"{ 
-      WORDPRESS_DB_NAMEwordpress +            "com.docker.network.driver.overlay.vxlanid_list""4097" 
-volumes+        }, 
-  db_data{}+        "Labels"null 
 +    } 
 +]
 </code> </code>
  
-Exécutez la commande docker-compose :+Vérifiez maintenant que les conteneurs se trouvent dans le réseau **nginx-net-2** :
  
 <code> <code>
-root@debian9:~/wordpress1# docker-compose up -d+root@manager:~# docker network inspect nginx-net-
 +
 +    { 
 +        "Name": "nginx-net-2", 
 +        "Id": "aez5huut9hd472qmldzf2tsud", 
 +        "Created": "2019-10-28T10:09:54.465105557+01:00", 
 +        "Scope": "swarm", 
 +        "Driver": "overlay", 
 +        "EnableIPv6": false, 
 +        "IPAM":
 +            "Driver": "default", 
 +            "Options": null, 
 +            "Config":
 +                { 
 +                    "Subnet": "10.0.1.0/24", 
 +                    "Gateway": "10.0.1.1" 
 +                } 
 +            ] 
 +        }, 
 +        "Internal": false, 
 +        "Attachable": false, 
 +        "Ingress": false, 
 +        "ConfigFrom":
 +            "Network": "" 
 +        }, 
 +        "ConfigOnly": false, 
 +        "Containers":
 +            "0bf159064e30d5e788a12baca53ee8e9504a2d7300017fb268cb9e90caaea27a":
 +                "Name": "my-nginx.2.81pveqac42zesvuulpbiho7k6", 
 +                "EndpointID": "25c9587e76cfca10d17b10fa967186bc73ca6b444cc2689e43a7243f5d1795b2", 
 +                "MacAddress": "02:42:0a:00:01:05", 
 +                "IPv4Address": "10.0.1.5/24", 
 +                "IPv6Address": "" 
 +            }, 
 +            "74e656da8c670fca23270078565af164c4d42415f012ff51ccb02395c6d121e9":
 +                "Name": "my-nginx.3.mjj1bsguaaewk61dw7yxxjdlu", 
 +                "EndpointID": "2be3c3e0286d3afb5ba47bbd903151a4d337a45743cb30c46595160223e02fba", 
 +                "MacAddress": "02:42:0a:00:01:07", 
 +                "IPv4Address": "10.0.1.7/24", 
 +                "IPv6Address": "" 
 +            }, 
 +            "lb-nginx-net-2":
 +                "Name": "nginx-net-2-endpoint", 
 +                "EndpointID": "768a4cc926b5c94a20904e5db500dc62b40a063077a49769ccccc007a6cb61ac", 
 +                "MacAddress": "02:42:0a:00:01:06", 
 +                "IPv4Address": "10.0.1.6/24", 
 +                "IPv6Address": "" 
 +            } 
 +        }, 
 +        "Options":
 +            "com.docker.network.driver.overlay.vxlanid_list": "4098" 
 +        }, 
 +        "Labels": {}, 
 +        "Peers":
 +            { 
 +                "Name": "69676ae46ab9", 
 +                "IP": "10.0.2.63" 
 +            }, 
 +            { 
 +                "Name": "1199cab4a6dd", 
 +                "IP": "10.0.2.62" 
 +            }, 
 +            { 
 +                "Name": "d058d363197d", 
 +                "IP": "10.0.2.64" 
 +            } 
 +        ] 
 +    } 
 +]
 </code> </code>
  
-Vérifiez que le Wordpress fonctionne :+Supprimez maintenant le service **my-nginx** ainsi que les deux réseaux overlay **nginx-net** et **nginx-net-2** :
  
 <code> <code>
-root@debian9:~/wordpress1lynx --dump http://10.0.2.60:8000 +root@manager:~# docker service rm my-nginx 
-   WordPress +my-nginx
-   Select a default language [English (United States)________]+
  
-   Continue +root@manager:~# docker network rm nginx-net nginx-net-2 
-    +nginx-net 
-root@debian9:~# docker ps -+nginx-net-2
-CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS                      PORTS                  NAMES +
-29afa2a7fdb5        wordpress:latest      "docker-entrypoint.s…"   21 minutes ago      Up 20 minutes               0.0.0.0:8000->80/tcp   wordpress1_wordpress_1 +
-... +
- +
-root@debian9:~/wordpress1# docker inspect wordpress1_wordpress_1 | grep IPAddress +
-            "SecondaryIPAddresses": null, +
-            "IPAddress": "172.17.0.7", +
-                    "IPAddress": "172.17.0.7", +
-                     +
-root@debian9:~/wordpress1# lynx --dump http://172.17.0.7 +
-   WordPress +
-   Select a default language [English (United States)________] +
- +
-   Continue+
 </code> </code>
  
-=====LAB #2 Docker Machine=====+====1.4 DNS container discovery====
  
-====2.1 - Présentation====+Le daemon Docker exécute un server DNS embarqué à l'adresse 127.0.0.11 qui permet la résolution des noms dans un réseau personnalisé. Si ce serveur est incapable de faire la résolution, il transfert la requête à tout serveur externe défini dans le conteneur.
  
-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).+Pour que le **DNS container discovery** fonctionne, les ports suivants doivent être ouverts sur les nœuds :
  
-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.+  * 2377/tcp 
 +  * 7946/tcp 
 +  * 7946/udp 
 +  * 4789/udp
  
-Pour installer docker-machine sur votre VM **debian9**, utilisez la commande suivante :+Créez maintenant le réseau de type overlay **test-net** :
  
 <code> <code>
-root@debian9:~# curl -L https://github.com/docker/machine/releases/download/v0.12.2/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machine && chmod +x /tmp/docker-machine && cp /tmp/docker-machine /usr/local/bin/docker-machine+root@manager:~# docker network create --driver=overlay --attachable test-net 
 +hrs25w4l951kkickhj6262mjg
 </code> </code>
  
-====2.2 Création de Machines Virtuelles Docker=====+<WRAP center round important 50%> 
 +**Important** : Notez que le **NETWORK-ID** ici est **hrs25w4l951kkickhj6262mjg**. 
 +</WRAP>
  
-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 :+Sur le Manager, démarrez un conteneur interactif appelé **alpine1** et qui se connecte au réseau **test-net** :
  
-^ Fournisseur ^ driver ^ +<code> 
-| [[https://aws.amazon.com/fr/|Amazon Web Services]] | [[https://docs.docker.com/machine/drivers/aws/|amazonec2]] | +root@manager:~# docker run -it --name alpine1 --network test-net alpine 
-| [[https://www.digitalocean.com/|Digital Ocean]] | [[https://docs.docker.com/machine/drivers/digital-ocean/|digitalocean]] | +Unable to find image 'alpine:latest' locally 
-| [[https://www.exoscale.ch/|Exoscale]] | [[https://docs.docker.com/machine/drivers/exoscale/|exoscale]] | +latestPulling from library/alpine 
-| [[https://cloud.google.com/compute/?hl=fr|Google Compute Engine]] | [[https://cloud.google.com/compute/?hl=fr|google]] | +89d9c30c1d48Pull complete  
-| [[http://www.softlayer.com/fr|IBM Softlayer]] | [[https://docs.docker.com/machine/drivers/soft-layer/|softlayer]] | +Digestsha256:c19173c5ada610a5989151111163d28a67368362762534d8a8121ce95cf2bd5a 
-| [[https://msdn.microsoft.com/fr-fr/library/hh831531(v=ws.11).aspx|Microsoft Hyper-V]] | [[https://docs.docker.com/machine/drivers/digital-ocean/|hyperv]] | +StatusDownloaded newer image for alpine:latest 
-| [[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]] | +</code>
-| [[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:+Listez les réseaux disponibles sur **Worker1** :
  
 <code> <code>
-root@debian9:~/wordpresscd ~ +root@worker1:~# docker network ls 
-root@debian9:~# apt install virtualbox-6.0+NETWORK ID          NAME                DRIVER              SCOPE 
 +3fe43b514f9d        bridge              bridge              local 
 +ee22b3e623ca        docker_gwbridge     bridge              local 
 +f3cb3bc3c581        host                host                local 
 +r8htcvc8oxmz        ingress             overlay             swarm 
 +de563e30d473        none                null                local
 </code> </code>
  
-Créez maintenant la machine virtuelle **manager1** :+<WRAP center round important 50%> 
 +**Important** : Notez que le réseau **test-net** n'a pas été créé. 
 +</WRAP> 
 + 
 +Démarrez maintenant un conteneur **alpine2** sur **Worker1** :
  
 <code> <code>
-root@debian9:~# docker-machine create --driver virtualbox manager1 +root@worker1:~# docker run -dit --name alpine2 --network test-net alpine 
-Creating CA/root/.docker/machine/certs/ca.pem +Unable to find image 'alpine:latest' locally 
-Creating client certificate: /root/.docker/machine/certs/cert.pem +latestPulling from library/alpine 
-Running pre-create checks... +89d9c30c1d48: Pull complete  
-(manager1) Image cache directory does not exist, creating it at /root/.docker/machine/cache... +Digestsha256:c19173c5ada610a5989151111163d28a67368362762534d8a8121ce95cf2bd5a 
-(manager1) No default Boot2Docker ISO found locally, downloading the latest release... +StatusDownloaded newer image for alpine:latest 
-(manager1) Latest release for github.com/boot2docker/boot2docker is v17.06.2-ce +5734e84cd460cdd33ce90970d98a96837a0305832a86fc4d86be38aecf51b23b
-(manager1) Downloading /root/.docker/machine/cache/boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v17.06.2-ce/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>
  
-Les options de la commande **docker-machine** sont :+Saisissez la commande **docker network ls** sur **Worker1** : 
  
 <code> <code>
-root@debian9:~# docker-machine --help +root@worker1:~# docker network ls 
-Usage: docker-machine [OPTIONS] COMMAND [arg...]+NETWORK ID          NAME                DRIVER              SCOPE 
 +3fe43b514f9d        bridge              bridge              local 
 +ee22b3e623ca        docker_gwbridge     bridge              local 
 +f3cb3bc3c581        host                host                local 
 +r8htcvc8oxmz        ingress             overlay             swarm 
 +de563e30d473        none                null                local 
 +hrs25w4l951k        test-net            overlay             swarm 
 +</code>
  
-Create and manage machines running Docker.+<WRAP center round important 50%> 
 +**Important** : Notez que le réseau **test-net**, ayant le même **NETWORK ID**, a été automatiquement créé lors de la création du conteneur **alpine2** 
 +</WRAP>
  
-Version0.12.2, build 9371605+Listez les réseaux disponibles sur **Worker2** :
  
-Author: +<code> 
-  Docker Machine Contributors - <https://github.com/docker/machine>+root@worker2:~# docker network ls 
 +NETWORK ID          NAME                DRIVER              SCOPE 
 +ff7308310f60        bridge              bridge              local 
 +0ce1d8369c29        docker_gwbridge     bridge              local 
 +f3cb3bc3c581        host                host                local 
 +r8htcvc8oxmz        ingress             overlay             swarm 
 +de563e30d473        none                null                local 
 +</code>
  
-Options: +<WRAP center round important 50%> 
-  --debug, -D Enable debug mode +**Important** Notez que le réseau **test-net** n'pas été créé
-  --storage-path, -s "/root/.docker/machine" Configures storage path [$MACHINE_STORAGE_PATH] +</WRAP>
-  --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 +
-  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 --helpfor more information on command+
-</code+
  
-Créez maintenant 5 travailleurs - **worker1** jusqu'à **worker5** :+Attachez vous au conteneur **alpine2** sur **Worker1** et essayez de contacter le conteneur **alpine1** :
  
 <code> <code>
-root@debian9:~# docker-machine create --driver virtualbox worker1 +root@worker1:~# docker ps -a 
-Running pre-create checks... +CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES 
-Creating machine... +ce9097b864dc        alpine              "/bin/sh"           23 minutes ago      Up 23 minutes                           alpine2
-(worker1) Copying /root/.docker/machine/cache/boot2docker.iso to /root/.docker/machine/machines/worker1/boot2docker.iso... +
-(worker1) Creating VirtualBox VM... +
-(worker1) Creating SSH key... +
-(worker1) Starting the VM... +
-(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> +root@worker1:~# docker attach alpine2 
-root@debian9:~# docker-machine create --driver virtualbox worker2 +/ #  
-... + 
-root@debian9:~# docker-machine create --driver virtualbox worker3 +/ # ping -c 2 alpine1 
-... +PING alpine1 (10.0.2.2)56 data bytes 
-root@debian9:~# docker-machine create --driver virtualbox worker4 +64 bytes from 10.0.2.2seq=0 ttl=64 time=1.874 ms 
-... +64 bytes from 10.0.2.2: seq=1 ttl=64 time=1.669 ms 
-root@debian9:~# docker-machine create --driver virtualbox worker5 + 
-...+--- alpine1 ping statistics --- 
 +2 packets transmitted, 2 packets received, 0% packet loss 
 +round-trip min/avg/max = 1.669/1.771/1.874 ms 
 +/ # 
 </code> </code>
  
-Les options de la sous-commande **create** de la commande **docker-machine** sont :+Retournez dans la VM **Manager** et essayez de contacter le conteneur **alpine2** à partir du conteneur **alpine1** :
  
 <code> <code>
-root@debian9:~# docker-machine create --help  +root@manager:~# docker attach alpine1 
-Usage: docker-machine create [OPTIONS] [arg...]+/ # 
  
-Create a machine+/ # ping -c 2 alpine2 
 +PING alpine2 (10.0.0.4): 56 data bytes 
 +64 bytes from 10.0.0.4: seq=0 ttl=64 time=0.666 ms 
 +64 bytes from 10.0.0.4: seq=1 ttl=64 time=1.239 ms
  
-Description: +--- alpine2 ping statistics --- 
-   Run 'docker-machine create --driver name' to include the create flags for that driver in the help text.+2 packets transmitted, 2 packets received, 0% packet loss 
 +round-trip min/avg/max = 0.666/0.952/1.239 ms 
 +/ #   
 +</code>
  
-Options: +Créez ensuite le conteneur **alpine3** sur le **Worker2** essayez de contacter le conteneur **alpine1** :
-    +
-   --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> +
  
-====2.3 Lister les VM Docker====+<code> 
 +root@worker2:~# docker run -it --rm --name alpine3 --network test-net alpine 
 +Unable to find image 'alpine:latest' locally 
 +latest: Pulling from library/alpine 
 +c9b1b535fdd9: Pull complete  
 +Digest: sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d 
 +Status: Downloaded newer image for alpine:latest 
 +/ # 
  
-Pour lister les VM Docker ainsi que leurs états, il convient d'utilise la sous-commande **ls** de la commande **docker-machine** :+/ # ping -c 2 alpine1 
 +PING alpine1 (10.0.2.2): 56 data bytes 
 +64 bytes from 10.0.2.2: seq=0 ttl=64 time=0.642 ms 
 +64 bytes from 10.0.2.2seq=1 ttl=64 time=1.684 ms
  
-<code> +--- alpine1 ping statistics --- 
-root@debian9:~# docker-machine ls +packets transmitted, 2 packets received, 0% packet loss 
-NAME       ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER        ERRORS +round-trip min/avg/max = 0.642/1.163/1.684 ms 
-manager1          virtualbox   Running   tcp://192.168.99.100:2376           v17.06.2-ce    +# exit
-worker1           virtualbox   Running   tcp://192.168.99.101:2376           v17.06.2-ce    +
-worker2    -        virtualbox   Running   tcp://192.168.99.102:2376           v17.06.2-ce    +
-worker3           virtualbox   Running   tcp://192.168.99.103:2376           v17.06.2-ce    +
-worker4    -        virtualbox   Running   tcp://192.168.99.104:2376           v17.06.2-ce    +
-worker5    -        virtualbox   Running   tcp://192.168.99.105:2376           v17.06.2-ce   +
 </code> </code>
  
-====2.4 - Obtenir l'adresse IP des VM==== +Arrêtez maintenant le conteneur **alpine2** sur **Worker1** :
- +
-Une autre façon d'obtenir les adresses IP des VM est d'utiliser la sous-commande **ip** :+
  
 <code> <code>
-root@debian9:~# docker-machine ip manager1 +root@worker1:~# docker container stop alpine2 
-192.168.99.100 +alpine2
-root@debian9:~# docker-machine ip worker1 +
-192.168.99.101 +
-root@debian9:~# docker-machine ip worker2 +
-192.168.99.102 +
-root@debian9:~# docker-machine ip worker3 +
-192.168.99.103 +
-root@debian9:~# docker-machine ip worker4 +
-192.168.99.104 +
-root@debian9:~# docker-machine ip worker5 +
-192.168.99.105+
 </code> </code>
  
-====2.5 - Se connecter à une VM Docker==== +Saisissez la commande **docker network ls** :
- +
-Pour se connecter à une VM Docker, il convient d'utiliser la sous-commande **ssh** de la commande **docker-machine** :+
  
 <code> <code>
-root@debian9:~# docker-machine ssh manager1 +root@worker1:~# docker network ls 
-                        ##         . +NETWORK ID          NAME                DRIVER              SCOPE 
-                  ## ## ##        == +3bb80f391804        bridge              bridge              local 
-               ## ## ## ## ##    === +ee22b3e623ca        docker_gwbridge     bridge              local 
-           /"""""""""""""""""\___/ === +f3cb3bc3c581        host                host                local 
-      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~ +r8htcvc8oxmz        ingress             overlay             swarm 
-           \______ o           __/ +de563e30d473        none                null                local
-                \         __/ +
-              \____\_______/ +
- _                   ____     _            _ +
-| |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __ +
-| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__| +
-| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ | +
-|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_| +
-Boot2Docker version 17.06.2-ce, build HEAD : ff16afa - Wed Sep  6 00:17:25 UTC 2017 +
-Docker version 17.06.2-ce, build cec0b72 +
-docker@manager1:~$ exit+
 </code> </code>
  
-<WRAP center round important> +<WRAP center round important 50%
-**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.+**Important** Notez que le réseau **test-net** a été supprimé.
 </WRAP> </WRAP>
  
-Installez maintenant le paquet **mlocate** :+Supprimez le conteneur **alpine2**:
  
 <code> <code>
-root@debian9:~# apt install mlocate +root@worker1:~# docker container rm alpine2 
-...+alpine2
 </code> </code>
  
-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/** :+Arrêtez le conteneur **alpine1** et supprimez le réseau **test-net** sur **Manager** :
  
 <code> <code>
-root@debian9:~updatedb +exit
-root@debian9:~# 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>+
  
-=====LAB #3 - Docker Swarm=====+root@manager:~docker container stop alpine1 
 +alpine1
  
-====3.1 Présentation====+root@manager:~# docker network ls 
 +NETWORK ID          NAME                DRIVER              SCOPE 
 +a604e7db6f95        bridge              bridge              local 
 +d4c9b0c9437a        docker_gwbridge     bridge              local 
 +f3cb3bc3c581        host                host                local 
 +jxu667wzmj2u        ingress             overlay             swarm 
 +de563e30d473        none                null                local 
 +518l09lcjhsp        test-net            overlay             swarm
  
-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.  +root@manager:~# docker network rm test-net 
- +test-net
-====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> +
-root@debian9:~# docker-machine ssh manager1 +
-docker@manager1:~$ docker swarm init --advertise-addr 192.168.99.100 +
-Swarm initialized: current node (yuwpmvtfmdxn8i7nllkyzkxkp) is now a manager. +
- +
-To add a worker to this swarm, run the following command: +
- +
-    docker swarm join --token SWMTKN-1-5bd9w9tapfqmd41f2psqdkoqwfo48fqsznnalk2slc28vlp6uh-004kp8y71m09nd7p8ft7ldku0 192.168.99.100:2377 +
- +
-To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.+
 </code> </code>
  
-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.+====2.5 - Création d'un Réseau overlay Personnalisé====
  
-====3.3 - Le Statut Leader==== +Il est possible de créer un réseau overlay personnaliséDans ce cas là, il convient de supprimer le réseau ingress déjà existant :
- +
-Consultez le statut de la VM Docker manager1 :+
  
 <code> <code>
-docker@manager1:~docker node ls +root@manager:~# docker network rm ingress 
-ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS +WARNING! Before removing the routing-mesh network, make sure all the nodes in your swarm run the same docker engine version. Otherwise, removal may not be effective and functionality of newly create ingress networks will be impaired. 
-yuwpmvtfmdxn8i7nllkyzkxkp *   manager1            Ready               Active              Leader+Are you sure you want to continue? [y/N] y 
 +ingress
 </code> </code>
  
-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. +Créez ensuite votre réseau personnalisé :
- +
-Pour connaître le token nécessaire pour rejoindre swarm en tant que nœud de gestion, saisissez la commande suivante :+
  
 <code> <code>
-docker@manager1:~docker swarm join-token manager +root@manager:~docker network create --driver overlay --ingress --subnet=10.11.0.0/16 --gateway=10.11.0.2 --opt com.docker.network.driver.mtu=1200 my-ingress 
-To add a manager to this swarm, run the following command:+44ozn3vtg23zkksrvloxuulcl
  
-    docker swarm join --token SWMTKN-1-5bd9w9tapfqmd41f2psqdkoqwfo48fqsznnalk2slc28vlp6uh-8rvbxvqewsrv6yyts7z2lq9pt 192.168.99.100:2377+root@manager:~# docker network ls 
 +NETWORK ID          NAME                DRIVER              SCOPE 
 +24be8a0f0ef5        bridge              bridge              local 
 +d4c9b0c9437a        docker_gwbridge     bridge              local 
 +f3cb3bc3c581        host                host                local 
 +44ozn3vtg23z        my-ingress          overlay             swarm 
 +de563e30d473        none                null                local
 </code> </code>
  
-====3.4 - Rejoindre le Swarm==== +Créez de nouveau le service **my-nginx** :
- +
-Rejoignez les 5 machines travailleurs à swarm en utilisant le token **worker** :+
  
 <code> <code>
-docker@worker1:~docker swarm join --token SWMTKN-1-5bd9w9tapfqmd41f2psqdkoqwfo48fqsznnalk2slc28vlp6uh-004kp8y71m09nd7p8ft7ldku0 192.168.99.100:2377 +root@manager:~docker service create --name my-nginx --publish target=80,published=80 --replicas=5 nginx 
-This node joined a swarm as a worker. +gp1iozmbi25dx3skn00m6suoz 
-</code>+overall progress5 out of 5 tasks  
 +1/5: running   [==================================================> 
 +2/5: running   [==================================================>]  
 +3/5: running   [==================================================>]  
 +4/5: running   [==================================================>]  
 +5/5: running   [==================================================>]  
 +verify: Service converged
  
-<code> +root@manager:~docker service ls 
-docker@worker2:~docker swarm join --token SWMTKN-1-5bd9w9tapfqmd41f2psqdkoqwfo48fqsznnalk2slc28vlp6uh-004kp8y71m09nd7p8ft7ldku0 192.168.99.100:2377 +ID                  NAME                MODE                REPLICAS            IMAGE               PORTS 
-This node joined a swarm as a worker. +gp1iozmbi25d        my-nginx            replicated          5/5                 nginx:latest        *:80->80/tcp
-</code>+
  
-<code> +root@manager:~docker service ps my-nginx 
-docker@worker3:~docker swarm join --token SWMTKN-1-5bd9w9tapfqmd41f2psqdkoqwfo48fqsznnalk2slc28vlp6uh-004kp8y71m09nd7p8ft7ldku0 192.168.99.100:2377 +ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE                ERROR               PORTS 
-This node joined swarm as a worker.+upmbwmtr76cm        my-nginx.         nginx:latest        worker1.i2tch.loc   Running             Running about a minute ago                        
 +qz6p1li7zmef        my-nginx.2          nginx:latest        worker2.i2tch.loc   Running             Running about a minute ago                        
 +me50mkhd11yk        my-nginx.3          nginx:latest        manager.i2tch.loc   Running             Running about a minute ago                        
 +sctjud70ihkl        my-nginx.4          nginx:latest        worker1.i2tch.loc   Running             Running about minute ago                        
 +kql9qx3phb73        my-nginx.5          nginx:latest        worker2.i2tch.loc   Running             Running about a minute ago    
 </code> </code>
  
-<code> +Consultez les informations concernant le service **my-nginx** 
-docker@worker4:~$ docker swarm join --token SWMTKN-1-5bd9w9tapfqmd41f2psqdkoqwfo48fqsznnalk2slc28vlp6uh-004kp8y71m09nd7p8ft7ldku0 192.168.99.100:2377 +
-This node joined a swarm as a worker. +
-</code>+
  
 <code> <code>
-docker@worker5:~docker swarm join --token SWMTKN-1-5bd9w9tapfqmd41f2psqdkoqwfo48fqsznnalk2slc28vlp6uh-004kp8y71m09nd7p8ft7ldku0 192.168.99.100:2377 +root@manager:~docker service inspect my-nginx 
-This node joined a swarm as a worker.+
 +    { 
 +        "ID": "gp1iozmbi25dx3skn00m6suoz", 
 +        "Version":
 +            "Index": 230 
 +        }, 
 +        "CreatedAt": "2019-10-28T14:49:33.6719228Z", 
 +        "UpdatedAt": "2019-10-28T14:49:33.679624758Z", 
 +        "Spec":
 +            "Name": "my-nginx", 
 +            "Labels": {}, 
 +            "TaskTemplate":
 +                "ContainerSpec":
 +                    "Image": "nginx:latest@sha256:922c815aa4df050d4df476e92daed4231f466acc8ee90e0e774951b0fd7195a4", 
 +                    "Init": false, 
 +                    "StopGracePeriod": 10000000000, 
 +                    "DNSConfig": {}, 
 +                    "Isolation": "default" 
 +                }, 
 +                "Resources":
 +                    "Limits": {}, 
 +                    "Reservations": {} 
 +                }, 
 +                "RestartPolicy":
 +                    "Condition": "any", 
 +                    "Delay": 5000000000, 
 +                    "MaxAttempts":
 +                }, 
 +                "Placement":
 +                    "Platforms":
 +                        { 
 +                            "Architecture": "amd64", 
 +                            "OS": "linux" 
 +                        }, 
 +                        { 
 +                            "OS": "linux" 
 +                        }, 
 +                        { 
 +                            "Architecture": "arm64", 
 +                            "OS": "linux" 
 +                        }, 
 +                        { 
 +                            "Architecture": "386", 
 +                            "OS": "linux" 
 +                        }, 
 +                        { 
 +                            "Architecture": "ppc64le", 
 +                            "OS": "linux" 
 +                        }, 
 +                        { 
 +                            "Architecture": "s390x", 
 +                            "OS": "linux" 
 +                        } 
 +                    ] 
 +                }, 
 +                "ForceUpdate": 0, 
 +                "Runtime": "container" 
 +            }, 
 +            "Mode":
 +                "Replicated":
 +                    "Replicas":
 +                } 
 +            }, 
 +            "UpdateConfig":
 +                "Parallelism": 1
 +                "FailureAction": "pause", 
 +                "Monitor": 5000000000, 
 +                "MaxFailureRatio": 0, 
 +                "Order": "stop-first" 
 +            }, 
 +            "RollbackConfig":
 +                "Parallelism": 1, 
 +                "FailureAction": "pause", 
 +                "Monitor": 5000000000, 
 +                "MaxFailureRatio": 0, 
 +                "Order": "stop-first" 
 +            }, 
 +            "EndpointSpec":
 +                "Mode": "vip", 
 +                "Ports":
 +                    { 
 +                        "Protocol": "tcp", 
 +                        "TargetPort": 80, 
 +                        "PublishedPort": 80, 
 +                        "PublishMode": "ingress" 
 +                    } 
 +                ] 
 +            } 
 +        }, 
 +        "Endpoint":
 +            "Spec":
 +                "Mode": "vip", 
 +                "Ports":
 +                    { 
 +                        "Protocol": "tcp", 
 +                        "TargetPort": 80, 
 +                        "PublishedPort": 80, 
 +                        "PublishMode": "ingress" 
 +                    } 
 +                ] 
 +            }, 
 +            "Ports":
 +                { 
 +                    "Protocol": "tcp", 
 +                    "TargetPort": 80, 
 +                    "PublishedPort": 80, 
 +                    "PublishMode": "ingress" 
 +                } 
 +            ], 
 +            "VirtualIPs":
 +                { 
 +                    "NetworkID": "44ozn3vtg23zkksrvloxuulcl", 
 +                    "Addr": "10.11.0.1/16" 
 +                } 
 +            ] 
 +        } 
 +    } 
 +]
 </code> </code>
  
-Notez que les ports suivants doivent être ouverts sur un nœud worker : 22/tcp, 2376/tcp, 7946/tcp, 7946/udp et 4789/udp. +Vérifiez maintenant que les conteneurs se trouvent dans le réseau **my-ingress** :
- +
-L'état des VM Docker peut être consulter en utilisant de nouveau la commande **docker node ls** :+
  
 <code> <code>
-docker@manager1:~docker node ls +root@manager:~docker inspect my-ingress 
-ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS +
-1f5qtolgtonqmhjk5ppwc8x1b     worker1             Ready               Active               +    { 
-kmyjdwp9ojhzje4hlw7ffhuxv     worker2             Ready               Active               +        "Name": "my-ingress", 
-oyszb44k8yw5btz3c1wq2ot2e     worker4             Ready               Active               +        "Id": "l11ucu5ufjfwwz6e0umtygdqy", 
-p6jpyopzzy0zg4znegi63hzjq     worker5             Ready               Active               +        "Created": "2020-03-10T11:02:38.278429829+01:00", 
-yitkfnk99ecisrny9g3r9kfhk     worker3             Ready               Active               +        "Scope": "swarm", 
-yuwpmvtfmdxn8i7nllkyzkxkp *   manager1            Ready               Active              Leader+        "Driver": "overlay", 
 +        "EnableIPv6": false, 
 +        "IPAM": { 
 +            "Driver": "default", 
 +            "Options": null, 
 +            "Config":
 +                { 
 +                    "Subnet": "10.11.0.0/16", 
 +                    "Gateway": "10.11.0.2" 
 +                } 
 +            ] 
 +        }, 
 +        "Internal": false, 
 +        "Attachable": false, 
 +        "Ingress": true, 
 +        "ConfigFrom": { 
 +            "Network": "" 
 +        }, 
 +        "ConfigOnly": false, 
 +        "Containers": { 
 +            "6f0168ff5153b899af31098740de34997b12417ef7c0f3824938edf79b2bca7f":
 +                "Name": "my-nginx.3.me50mkhd11ykwz7aj07znloh1", 
 +                "EndpointID": "41531d43496f4723cb62cad1d57c5a088faebe79c430d04a1765022e31d8ae17", 
 +                "MacAddress": "02:42:0a:0b:00:05", 
 +                "IPv4Address": "10.11.0.5/16", 
 +                "IPv6Address": "" 
 +            }, 
 +            "my-ingress-sbox":
 +                "Name": "my-ingress-endpoint", 
 +                "EndpointID": "0205796eeb005ef77b3ea382fd1e72c312a58fd717b5a79ca6cacc7e090068e6", 
 +                "MacAddress": "02:42:0a:0b:00:0a", 
 +                "IPv4Address": "10.11.0.10/16", 
 +                "IPv6Address": "" 
 +            } 
 +        }, 
 +        "Options":
 +            "com.docker.network.driver.mtu": "1200", 
 +            "com.docker.network.driver.overlay.vxlanid_list": "4100" 
 +        }, 
 +        "Labels": {}, 
 +        "Peers":
 +            { 
 +                "Name": "9a00e8bc72fe", 
 +                "IP": "10.0.2.62" 
 +            }, 
 +            { 
 +                "Name": "3ea669d48ca2", 
 +                "IP": "10.0.2.64" 
 +            }, 
 +            { 
 +                "Name": "f30e39df1704", 
 +                "IP": "10.0.2.63" 
 +            } 
 +        ] 
 +    } 
 +]
 </code> </code>
  
-Notez que vous ne pouvez pas utiliser cette commande à partir d'un travailleur :+Supprimez maintenant le service **my-nginx** :
  
 <code> <code>
-docker@worker5:~docker node ls +root@manager:~docker service rm my-nginx 
-Error response from daemon: This node is not a swarm manager. Worker nodes can't be used to view or modify cluster state. Please run this command on a manager node or promote the current node to a manager.+my-nginx
 </code> </code>
  
-====3.5 Consulter les Informations de Swarm====+=====LAB #2 Gestion d'une Architecture de Microservices=====
  
-Il est possible de visualiser les informations concernant le swarm en utilisant la commande **docker info** :+Vous allez mettre en place une application simple, appelé **demo-voting-app** et développé par Docker, sous forme de microservices :
  
-<code> +{{ :elearning:workbooks:debian:6:avance:app.png?direct&400 |}}
-docker@manager1:~$ docker info +
-... +
-Swarmactive +
- NodeIDyuwpmvtfmdxn8i7nllkyzkxkp +
- Is Manager: true +
- ClusterID: sqll9xmii9qkrd35d1limn1od +
- Managers:+
- Nodes: 6 +
- Orchestration: +
-  Task History Retention Limit+
- Raft: +
-  Snapshot Interval: 10000 +
-  Number of Old Snapshots to Retain: 0 +
-  Heartbeat Tick: 1 +
-  Election Tick: 3 +
- Dispatcher: +
-  Heartbeat Period: 5 seconds +
- CA Configuration: +
-  Expiry Duration: 3 months +
-  Force Rotate: 0 +
- Root Rotation In Progress: false +
- Node Address: 192.168.99.100 +
- Manager Addresses: +
-  192.168.99.100:2377 +
-... +
-</code>+
  
-<WRAP center round important> +Dans cette application le conteneur **voting-app** permet de voter pour des **chats** ou des **chiens**. Cette application tourne sous Python et fournit une interface HTML :
-**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.- Démarrer un Service====+{{ :elearning:workbooks:debian:6:avance:kubernetes15.png?direct&800 |}}
  
-Dans cet exemplenous allons démarrer le service **nginx** avec les propriétés suivantes :+Lors de la vote, le résultat de celle-ci est stocké dans **Redis** dans une base de données en mémoire. Le résultat est ensuite passé au conteneur **Worker** qui tourne sous .NET et qui met à jour la base de données persistante dans le conteneur **db** qui tourne sous PostgreSQL.
  
-  Mappage du port nginx sur le port 80 de la machine hôte, +L'application **result-app** qui tourne sous NodeJS lit ensuite la table dans la base de données PostgreSQL et affiche le résultat sous forme HTML :
-  5 instances du service, +
-  Un nom unique de **web**.+
  
-<code> +{{ :elearning:workbooks:debian:6:avance:kubernetes16.png?direct&800 |}}
-docker@manager1:~$ docker service create --replicas 5 -p 80:80 --name web nginx +
-4xtuwgbvr17lvfzoumh1y4mq4 +
-Since --detach=false was not specified, tasks will be created in the background. +
-In a future release, --detach=false will become the default. +
-</code>+
  
-Pour consulter l'état de ce service, utilisez la commande **docker service ls** :+====2.1 - Mise en Place avec Docker Swarm avec des réseaux Overlay==== 
 + 
 +Cette application peut être mise en place sous docker swarm avec avec la commande **docker stack**. Un **stack** est un groupe de services. Premièrement, vérifiez l'état du Swarm :
  
 <code> <code>
-docker@manager1:~docker service ls +root@manager:~docker node ls 
-ID                  NAME                MODE                REPLICAS            IMAGE               PORTS +ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION 
-4xtuwgbvr17l        web                 replicated          5/5                 nginx:latest        *:80->80/tcp+b85hxlixbr1mh1txd1hrfe4us   manager.i2tch.loc   Ready               Active              Leader              19.03.4 
 +4sui75vvdhmet4qvt0zbvzlzl     worker1.i2tch.loc   Ready               Active                                  19.03.4 
 +lbjtg5o9kw3x6xg7frm07jfuw     worker2.i2tch.loc   Ready               Active                                  19.03.4
 </code> </code>
  
-Ce service fonctionne dans des conteneurs Docker :+Créez maintenant le fichier **docker-stack.yml** :
  
 <code> <code>
-docker@manager1:~docker service ps web +root@manager:~# vi docker-stack.yml 
-ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE                ERROR               PORTS +
-jkm2hapcthht        web.1               nginx:latest        worker3             Running             Running about a minute ago                        +
-q55eqdhr1qf1        web.2               nginx:latest        worker4             Running             Running about a minute ago                        +
-imqdkw4ei6gs        web.3               nginx:latest        manager1            Running             Running about a minute ago                        +
-k4vjd0g7ijww        web.4               nginx:latest        worker1             Running             Running about a minute ago                        +
-b7xbmy1npgf9        web.5               nginx:latest        worker2             Running             Running about a minute ago +
-</code>+
  
-<WRAP center round important> +root@manager:~# cat docker-stack.yml  
-**Important** Notez qu'il n'y a pas de conteneur sur worker5+version: "3" 
-</WRAP>+services:
  
-Pour constater le lancement du daemon nginx, lancez la commande **docker ps** sur la machine **manager1** :+  redis: 
 +    image: redis:alpine 
 +    networks: 
 +      - frontend 
 +    deploy: 
 +      replicas: 1 
 +      update_config: 
 +        parallelism:
 +        delay: 10s 
 +      restart_policy: 
 +        condition: on-failure 
 +  db: 
 +    image: postgres:9.4 
 +    environment: 
 +      POSTGRES_USER: "postgres" 
 +      POSTGRES_PASSWORD: "postgres" 
 +    volumes: 
 +      - db-data:/var/lib/postgresql/data 
 +    networks: 
 +      - backend 
 +    deploy: 
 +      placement: 
 +        constraints: [node.role == manager] 
 +  vote: 
 +    image: dockersamples/examplevotingapp_vote:before 
 +    ports: 
 +      - 5000:80 
 +    networks: 
 +      - frontend 
 +    depends_on: 
 +      - redis 
 +    deploy: 
 +      replicas: 2 
 +      update_config: 
 +        parallelism:
 +      restart_policy: 
 +        condition: on-failure 
 +  result: 
 +    image: dockersamples/examplevotingapp_result:before 
 +    ports: 
 +      - 5001:80 
 +    networks: 
 +      - backend 
 +    depends_on: 
 +      - db 
 +    deploy: 
 +      replicas: 1 
 +      update_config: 
 +        parallelism:
 +        delay: 10s 
 +      restart_policy: 
 +        condition: on-failure
  
-<code> +  worker: 
-docker@manager1:~$ docker ps +    image: dockersamples/examplevotingapp_worker 
-CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES +    networks: 
-4107cb687eda        nginx:latest        "nginx -g 'daemon ..."   2 minutes ago       Up 2 minutes        80/tcp              web.3.imqdkw4ei6gskwacnb4pime5f+      - frontend 
 +      - backend 
 +    depends_on: 
 +      - db 
 +      - redis 
 +    deploy: 
 +      mode: replicated 
 +      replicas: 1 
 +      labels: [APP=VOTING] 
 +      restart_policy
 +        condition: on-failure 
 +        delay10s 
 +        max_attempts:
 +        window: 120s 
 +      placement: 
 +        constraints: [node.role == manager] 
 + 
 +  visualizer: 
 +    image: dockersamples/visualizer:stable 
 +    ports: 
 +      - "8080:8080" 
 +    stop_grace_period: 1m30s 
 +    volumes: 
 +      "/var/run/docker.sock:/var/run/docker.sock" 
 +    deploy: 
 +      placement: 
 +        constraints: [node.role == manager] 
 + 
 +networks: 
 +  frontend: 
 +  backend: 
 + 
 +volumes: 
 +  db-data:
 </code> </code>
  
-Connectez-vous sur chaque VM Docker pour constater que le service nginx fonctionne :+Dans ce fichier on peut constater 6 services, **redis**, **db**, **vote**, **result**, **worker** et **visualizer**. Les 5 premiers services forment ensemble l'application tandis que le service **visualizer** nous permettra de voir comment l'application a été mise en place.
  
-<code> +Dans un premier temps, regardez la clef **deploy** du service **worker** :
-docker@manager1:/$ curl 192.168.99.100 +
-<!DOCTYPE html> +
-<html> +
-<head> +
-<title>Welcome to nginx!</title> +
-<style> +
-    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 +<file
-<a href="http://nginx.org/">nginx.org</a>.<br/> +... 
-Commercial support is available at +    deploy: 
-<a href="http://nginx.com/">nginx.com</a>.</p>+      mode: replicated 
 +      replicas: 1 
 +      labels: [APP=VOTING] 
 +      restart_policy: 
 +        condition: on-failure 
 +        delay: 10s 
 +        max_attempts:
 +        window: 120s 
 +      placement: 
 +        constraints: [node.role == manager] 
 +..
 +</file>
  
-<p><em>Thank you for using nginx.</em></p> +La clef **deploy** permet de spécifier des options lors du déploiement du service :
-</body> +
-</html> +
-docker@manager1:/$ curl 192.168.99.101 +
-<!DOCTYPE html> +
-<html> +
-<head> +
-<title>Welcome to nginx!</title> +
-<style> +
-    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 +  * **mode** - Il existe deux types de services**Replicated** où on spécifie le nombre d'instances que Docker doit mettre en place sur les hôtes **disponibles** en fonction de la valeur de **replicas** et **Global** qui implique que Docker démarrera une instance du service sur chaque hôte chaque fois qu'un hôte devient disponible.
-<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> +{:elearning:workbooks:docker2:tvl1m.png?nolink&400 |}}
-</body> +
-</html> +
-docker@manager1:/$ curl 192.168.99.102 +
-<!DOCTYPE html> +
-<html> +
-<head> +
-<title>Welcome to nginx!</title> +
-<style> +
-    body { +
-        width35em; +
-        margin0 auto; +
-        font-familyTahoma, 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 +  * **replicas** - spécifie le nombre de replicas 
-<a href="http://nginx.org/">nginx.org</a>.<br/> +  * **restart_policy** spécifie ce qui se passe en cas d'arrêt du serviceDans le cas ci-dessus, docker va essayer de re-démarrer le service **3** fois (**max_attempts**) à des intervalles de **10** secondes (**delay**) en attendant chaque fois **120** secondes (**window**) pour constater si le service s'est effectivement re-démarré, 
-Commercial support is available at +  * **placement** - spécifie où le service doit être démarré.
-<a href="http://nginx.com/">nginx.com</a>.</p>+
  
-<p><em>Thank you for using nginx.</em></p> +Déployez maintenant le stack :
-</body> +
-</html> +
-docker@manager1:/$ curl 192.168.99.103 +
-<!DOCTYPE html> +
-<html> +
-<head> +
-<title>Welcome to nginx!</title> +
-<style> +
-    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 +<code
-<a href="http://nginx.org/">nginx.org</a>.<br/> +root@manager:~# docker stack deploy -c docker-stack.yml app 
-Commercial support is available at +Creating network app_backend 
-<a href="http://nginx.com/">nginx.com</a>.</p>+Creating network app_default 
 +Creating network app_frontend 
 +Creating service app_worker 
 +Creating service app_visualizer 
 +Creating service app_redis 
 +Creating service app_db 
 +Creating service app_vote 
 +Creating service app_result 
 +</code>
  
-<p><em>Thank you for using nginx.</em></p+<WRAP center round important 50%
-</body> +**Important** - Notez que chaque réseau et chaque service a comme préfixe le nom de l'application **app**
-</html> +</WRAP>
-docker@manager1:/$ curl 192.168.99.104 +
-<!DOCTYPE html> +
-<html> +
-<head> +
-<title>Welcome to nginx!</title> +
-<style> +
-    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 +Consultez maintenant l'état du stack :
-<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+<code
-</body> +root@manager:~# docker stack ls 
-</html> +NAME                SERVICES            ORCHESTRATOR 
-docker@manager1:/$ curl 192.168.99.105 +app                                   Swarm 
-<!DOCTYPE html> +</code>
-<html> +
-<head> +
-<title>Welcome to nginx!</title> +
-<style> +
-    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 +Consultez ensuite l'état des services :
-<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+<code> 
-</body+root@manager:~# docker service ls 
-</html>+ID                  NAME                MODE                REPLICAS            IMAGE                                          PORTS 
 +d0i4ac4fshw0        app_db              replicated          1/1                 postgres:9.4                                    
 +funp5kboyip1        app_redis           replicated          1/1                 redis:alpine                                    
 +dpdkc49oj671        app_result          replicated          1/1                 dockersamples/examplevotingapp_result:before   *:5001->80/tcp 
 +vrkahv38v5mn        app_visualizer      replicated          1/1                 dockersamples/visualizer:stable                *:8080->8080/tcp 
 +t4u16cpdrx21        app_vote            replicated          2/2                 dockersamples/examplevotingapp_vote:before     *:5000->80/tcp 
 +so40eljbcviy        app_worker          replicated          1/1                 dockersamples/examplevotingapp_worker:latest  
 </code> </code>
  
-<WRAP center round important> +<WRAP center round important 50%
-**Important** Notez que le service est même disponible en consultant l'adresse IP de worker5.+**Important** Notez que la configuration du service **visualizer** a exposé le port **8080**. De cette façon, ce service est disponible sur le port 8080 de chaque nœud dans la swarm.
 </WRAP> </WRAP>
  
-====3.7 - Augmentation et Réduction du Service====+Retournez à la fenêtre d'Apache Guacamole dans le navigateur de **votre** ordinateurCliquez sur la connexion **Debian11_10.0.2.46_VNC**. Lancez ensuite un navigateur Internet. Naviguez à l'URL http://10.0.2.62:8080 et consultez le service **visualizer** :
  
-Actuellement, il existe 5 conteneurs en cours d'exécutionPour procéder à un scale-up à 8 conteneurs, il convient d'utiliser la commande **docker service scale** :+{{ :elearning:workbooks:docker:docker001.png?direct&600 |}} 
 + 
 +{{ :elearning:workbooks:docker:docker001.png |}} 
 + 
 +Comme vous pouvez constater, conformément au fichier **docker-stack.yml**, les trois conteneurs **db**, **worker** et **visualizer** ont été démarrés sur le nœud manager. 
 + 
 +Retournez à votre connexion SSH et consultez l'état des réseaux dans les trois nœuds :
  
 <code> <code>
-docker@manager1:/$ docker service scale web=8 +root@manager:~# docker network ls 
-web scaled to 8+NETWORK ID          NAME                               DRIVER              SCOPE 
 +sw489bb290zb        app_backend                        overlay             swarm 
 +smuxoglyudpo        app_default                        overlay             swarm 
 +lfizui95od90        app_frontend                       overlay             swarm 
 +24be8a0f0ef5        bridge                             bridge              local 
 +d4c9b0c9437a        docker_gwbridge                    bridge              local 
 +f3cb3bc3c581        host                               host                local 
 +x7l4mk4ldb75        my-ingress                         overlay             swarm 
 +de563e30d473        none                               null                local
 </code> </code>
  
-Notez que la commande **docker service ls** confirme le fait qu'il y a 8 replicas :+<WRAP center round important 50%> 
 +**Important** : Notez que les trois réseaux créés sont de type **overlay**
 +</WRAP>
  
 <code> <code>
-docker@manager1:/$ docker service ls +root@worker1:~# docker network ls 
-ID                  NAME                MODE                REPLICAS            IMAGE               PORTS +NETWORK ID          NAME                DRIVER              SCOPE 
-4xtuwgbvr17l        web                 replicated          8/8                 nginx:latest        *:80->80/tcp+qhysvpoolsw0        app_frontend        overlay             swarm 
 +f9a69d02de3b        bridge              bridge              local 
 +ee22b3e623ca        docker_gwbridge     bridge              local 
 +f3cb3bc3c581        host                host                local 
 +x7l4mk4ldb75        my-ingress          overlay             swarm 
 +de563e30d473        none                null                local
 </code> </code>
  
-Des trois replicas supplémentaires, deux ont été lancés sur worker5 tandis que le troisième a été lancé sur worker1 :+<WRAP center round important 50%> 
 +**Important** : Notez que seul le réseau **app_frontend** a été créé dans **worker1**. 
 +</WRAP>
  
 <code> <code>
-docker@manager1:/$ docker service ps web +root@worker2:~# docker network ls 
-ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE            ERROR               PORTS +NETWORK ID          NAME                DRIVER              SCOPE 
-jkm2hapcthht        web.1               nginx:latest        worker3             Running             Running 20 minutes ago                        +s4gbgi4isp1i        app_backend         overlay             swarm 
-q55eqdhr1qf1        web.2               nginx:latest        worker4             Running             Running 20 minutes ago                        +qhysvpoolsw0        app_frontend        overlay             swarm 
-imqdkw4ei6gs        web.3               nginx:latest        manager1            Running             Running 20 minutes ago                        +0e6c118bf3fd        bridge              bridge              local 
-k4vjd0g7ijww        web.4               nginx:latest        worker1             Running             Running 20 minutes ago                        +0ce1d8369c29        docker_gwbridge     bridge              local 
-b7xbmy1npgf9        web.5               nginx:latest        worker2             Running             Running 20 minutes ago                        +f3cb3bc3c581        host                host                local 
-kg3bivcg0wln        web.6               nginx:latest        worker5             Running             Running 47 seconds ago                        +x7l4mk4ldb75        my-ingress          overlay             swarm 
-ik3u0jfgey64        web.7               nginx:latest        worker5             Running             Running 47 seconds ago                        +de563e30d473        none                null                local
-6bw5ptw7xao8        web.8               nginx:latest        worker1             Running             Running 57 seconds ago +
 </code> </code>
  
-====3.8 - Consulter le Statut d'un Noeud====+<WRAP center round important 50%> 
 +**Important** : Notez que les deux réseaux **app_frontend** et **app_backend** ont été créés dans **worker2**. 
 +</WRAP>
  
-Pour se renseigner sur le statut du nœud courant, il convient d'utiliser la commande **docker node inspect** avec le mot clef **self** :+Consultez les informations concernant le réseau **app_backend** :
  
 <code> <code>
-docker@manager1:/$ docker node inspect self+root@manager:~# docker inspect app_backend
 [ [
     {     {
-        "ID": "yuwpmvtfmdxn8i7nllkyzkxkp", +        "Name": "app_backend", 
-        "Version": { +        "Id": "s4gbgi4isp1i5wjpgnf4uci2a", 
-            "Index": 9+        "Created": "2019-11-03T17:30:56.822222239+01:00", 
 +        "Scope": "swarm", 
 +        "Driver": "overlay", 
 +        "EnableIPv6": false, 
 +        "IPAM": { 
 +            "Driver": "default", 
 +            "Options": null, 
 +            "Config":
 +                { 
 +                    "Subnet": "10.0.3.0/24", 
 +                    "Gateway": "10.0.3.1" 
 +                } 
 +            ]
         },         },
-        "CreatedAt": "2017-09-08T11:43:55.289178512Z"+        "Internal": false
-        "UpdatedAt": "2017-09-08T11:43:55.89870884Z"+        "Attachable": false
-        "Spec": { +        "Ingress": false, 
-            "Labels": {}, +        "ConfigFrom": { 
-            "Role": "manager", +            "Network": ""
-            "Availability": "active"+
         },         },
-        "Description": { +        "ConfigOnly": false, 
-            "Hostname": "manager1", +        "Containers": { 
-            "Platform": { +            "7d0b28e4e1828b437af1a41f322acb5cf19afc25c42303986dd2c7b4d5aea568": 
-                "Architecture": "x86_64", +                "Name": "app_db.1.s6g6w47k532rvaeoyske8as9i", 
-                "OS": "linux"+                "EndpointID": "c26795c837f6dc736a3f9be34525ae505e9db6381a2144bb62087b3ee6c7ff25", 
 +                "MacAddress": "02:42:0a:00:03:03", 
 +                "IPv4Address": "10.0.3.3/24", 
 +                "IPv6Address": ""
             },             },
-            "Resources": { +            "ef7227281d297b001bb0f60ac81a0c9926e8fb663a7f43eb201cced632dc5564": { 
-                "NanoCPUs": 1000000000+                "Name": "app_worker.1.38kniuqoe1vfyonwdcytlhpqo"
-                "MemoryBytes": 1044123648+                "EndpointID": "990065eec5062ff159e82bc1e4666fd098d5597439221995af4f01040ab24599", 
 +                "MacAddress": "02:42:0a:00:03:09", 
 +                "IPv4Address": "10.0.3.9/24", 
 +                "IPv6Address": ""
             },             },
-            "Engine": { +            "lb-app_backend": { 
-                "EngineVersion": "17.06.2-ce", +                "Name": "app_backend-endpoint", 
-                "Labels": +                "EndpointID": "913845cbab9a6c3011eaaa87fcc66f10268b5e11554be9f1a20b1078f7b9b8a4", 
-                    "provider": "virtualbox" +                "MacAddress": "02:42:0a:00:03:04", 
-                }+                "IPv4Address": "10.0.3.4/24", 
-                "Plugins": +                "IPv6Address": ""
-                    { +
-                        "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": "logentries" +
-                    }, +
-                    { +
-                        "Type": "Log", +
-                        "Name": "splunk" +
-                    }, +
-                    { +
-                        "Type": "Log", +
-                        "Name": "syslog" +
-                    }, +
-                    { +
-                        "Type": "Network", +
-                        "Name": "bridge" +
-                    }, +
-                    { +
-                        "Type": "Network", +
-                        "Name": "host" +
-                    }, +
-                    { +
-                        "Type": "Network", +
-                        "Name": "macvlan" +
-                    }, +
-                    { +
-                        "Type": "Network", +
-                        "Name": "null" +
-                    }, +
-                    { +
-                        "Type": "Network", +
-                        "Name": "overlay" +
-                    }, +
-                    { +
-                        "Type": "Volume", +
-                        "Name": "local" +
-                    } +
-                +
-            }, +
-            "TLSInfo": +
-                "TrustRoot": "-----BEGIN CERTIFICATE-----\nMIIBajCCARCgAwIBAgIUNuU4I89kxId2QXulofRKxJa9XRcwCgYIKoZIzj0EAwIw\nEzERMA8GA1UEAxMIc3dhcm0tY2EwHhcNMTcwOTA4MTEzOTAwWhcNMzcwOTAzMTEz\nOTAwWjATMREwDwYDVQQDEwhzd2FybS1jYTBZMBMGByqGSM49AgEGCCqGSM49AwEH\nA0IABEqgLUbyjyNuP35aAzW+aqVB8AkghvpF5hq1KnMveHbl4Ilr+EyDjlYZkbnt\nGb/xmsy/tOP8uz598ZX/JlR4fZyjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMB\nAf8EBTADAQH/MB0GA1UdDgQWBBSzoKGrN0ELfEIMsjxuYj5LAckD2jAKBggqhkjO\nPQQDAgNIADBFAiB34DOvDtIYjJ+GzbPMGu9Dd/cJGvy7CJg1tNUG3SoOrAIhAJZ4\nTJBucTomFSDsj5Y/R6TfhcpXpsksk7JwYgEglu44\n-----END CERTIFICATE-----\n", +
-                "CertIssuerSubject": "MBMxETAPBgNVBAMTCHN3YXJtLWNh", +
-                "CertIssuerPublicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAESqAtRvKPI24/floDNb5qpUHwCSCG+kXmGrUqcy94duXgiWv4TIOOVhmRue0Zv/GazL+04/y7Pn3xlf8mVHh9nA=="+
             }             }
         },         },
-        "Status": { +        "Options": { 
-            "State": "ready", +            "com.docker.network.driver.overlay.vxlanid_list": "4101" 
-            "Addr": "192.168.99.100"+        }
 +        "Labels": 
 +            "com.docker.stack.namespace": "app"
         },         },
-        "ManagerStatus": { +        "Peers": [ 
-            "Leader": true+            
-            "Reachability": "reachable", +                "Name": "377986fb7d5a"
-            "Addr": "192.168.99.100:2377+                "IP": "10.0.2.62" 
-        }+            }
 +            
 +                "Name": "5cc4b863da9f", 
 +                "IP": "10.0.2.64
 +            } 
 +        ]
     }     }
 ] ]
- 
 </code> </code>
  
-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é :+<WRAP center round important 50%> 
 +**Important** : Notez que le réseau est **10.0.3.0/24** et la passerelle **10.0.3.1**
 +</WRAP> 
 + 
 +Consultez les informations concernant le réseau **app_frontend** :
  
 <code> <code>
-docker@manager1:/$ docker node inspect worker1+root@manager:~# docker inspect app_frontend
 [ [
     {     {
-        "ID": "1f5qtolgtonqmhjk5ppwc8x1b", +        "Name": "app_frontend", 
-        "Version": { +        "Id": "qhysvpoolsw0318gsubbvd3rx", 
-            "Index": 15+        "Created": "2019-11-03T17:31:27.354293132+01:00", 
 +        "Scope": "swarm", 
 +        "Driver": "overlay", 
 +        "EnableIPv6": false, 
 +        "IPAM": { 
 +            "Driver": "default", 
 +            "Options": null, 
 +            "Config":
 +                { 
 +                    "Subnet": "10.0.2.0/24", 
 +                    "Gateway": "10.0.2.1" 
 +                } 
 +            ]
         },         },
-        "CreatedAt": "2017-09-08T11:48:42.011596185Z"+        "Internal": false
-        "UpdatedAt": "2017-09-08T11:48:42.093455479Z"+        "Attachable": false
-        "Spec": { +        "Ingress": false, 
-            "Labels": {}, +        "ConfigFrom": { 
-            "Role": "worker", +            "Network": ""
-            "Availability": "active"+
         },         },
-        "Description": { +        "ConfigOnly": false, 
-            "Hostname": "worker1", +        "Containers": { 
-            "Platform": { +            "ef7227281d297b001bb0f60ac81a0c9926e8fb663a7f43eb201cced632dc5564": 
-                "Architecture": "x86_64", +                "Name": "app_worker.1.38kniuqoe1vfyonwdcytlhpqo", 
-                "OS": "linux"+                "EndpointID": "3fad9773920412464b6aeee59f8d9ffc5aac2e937b88dc384268591cf7d21fb9", 
 +                "MacAddress": "02:42:0a:00:02:0a", 
 +                "IPv4Address": "10.0.2.10/24", 
 +                "IPv6Address": ""
             },             },
-            "Resources": { +            "lb-app_frontend": { 
-                "NanoCPUs": 1000000000+                "Name": "app_frontend-endpoint"
-                "MemoryBytes": 1044123648+                "EndpointID": "343887373c1f92ac08b271ee52dd160089eeed7cad13b7924e438919254b6442", 
 +                "MacAddress": "02:42:0a:00:02:0b", 
 +                "IPv4Address": "10.0.2.11/24", 
 +                "IPv6Address": "" 
 +            } 
 +        }, 
 +        "Options":
 +            "com.docker.network.driver.overlay.vxlanid_list": "4100" 
 +        }, 
 +        "Labels":
 +            "com.docker.stack.namespace": "app" 
 +        }, 
 +        "Peers":
 +            { 
 +                "Name": "0e21ba1bbfab", 
 +                "IP": "10.0.2.63"
             },             },
-            "Engine": +            { 
-                "EngineVersion": "17.06.2-ce", +                "Name": "5cc4b863da9f", 
-                "Labels": +                "IP": "10.0.2.64"
-                    "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": "logentries" +
-                    }, +
-                    { +
-                        "Type": "Log", +
-                        "Name": "splunk" +
-                    }, +
-                    { +
-                        "Type": "Log", +
-                        "Name": "syslog" +
-                    }, +
-                    { +
-                        "Type": "Network", +
-                        "Name": "bridge" +
-                    }, +
-                    { +
-                        "Type": "Network", +
-                        "Name": "host" +
-                    }, +
-                    { +
-                        "Type": "Network", +
-                        "Name": "macvlan" +
-                    }, +
-                    { +
-                        "Type": "Network", +
-                        "Name": "null" +
-                    }, +
-                    { +
-                        "Type": "Network", +
-                        "Name": "overlay" +
-                    }, +
-                    { +
-                        "Type": "Volume", +
-                        "Name": "local" +
-                    } +
-                ]+
             },             },
-            "TLSInfo": +            { 
-                "TrustRoot": "-----BEGIN CERTIFICATE-----\nMIIBajCCARCgAwIBAgIUNuU4I89kxId2QXulofRKxJa9XRcwCgYIKoZIzj0EAwIw\nEzERMA8GA1UEAxMIc3dhcm0tY2EwHhcNMTcwOTA4MTEzOTAwWhcNMzcwOTAzMTEz\nOTAwWjATMREwDwYDVQQDEwhzd2FybS1jYTBZMBMGByqGSM49AgEGCCqGSM49AwEH\nA0IABEqgLUbyjyNuP35aAzW+aqVB8AkghvpF5hq1KnMveHbl4Ilr+EyDjlYZkbnt\nGb/xmsy/tOP8uz598ZX/JlR4fZyjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMB\nAf8EBTADAQH/MB0GA1UdDgQWBBSzoKGrN0ELfEIMsjxuYj5LAckD2jAKBggqhkjO\nPQQDAgNIADBFAiB34DOvDtIYjJ+GzbPMGu9Dd/cJGvy7CJg1tNUG3SoOrAIhAJZ4\nTJBucTomFSDsj5Y/R6TfhcpXpsksk7JwYgEglu44\n-----END CERTIFICATE-----\n", +                "Name": "377986fb7d5a", 
-                "CertIssuerSubject": "MBMxETAPBgNVBAMTCHN3YXJtLWNh", +                "IP": "10.0.2.62"
-                "CertIssuerPublicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAESqAtRvKPI24/floDNb5qpUHwCSCG+kXmGrUqcy94duXgiWv4TIOOVhmRue0Zv/GazL+04/y7Pn3xlf8mVHh9nA=="+
             }             }
-        }, +        ]
-        "Status":+
-            "State": "ready", +
-            "Addr": "192.168.99.101" +
-        }+
     }     }
 ] ]
 </code> </code>
  
-L'option **--pretty** produit une sortie plus facilement lisible :+<WRAP center round important 50%> 
 +**Important** : Notez que le réseau est **10.0.2.0/24** et la passerelle **10.0.2.1**. 
 +</WRAP>
  
-<code> +Consultez les informations concernant le réseau **app_default** :
-docker@manager1:/$ docker node inspect --pretty worker1 +
-ID:             1f5qtolgtonqmhjk5ppwc8x1b +
-Hostname:              worker1 +
-Joined at:              2017-09-08 11:48:42.011596185 +0000 utc +
-Status: +
- State:         Ready +
- Availability:          Active +
- Address:         192.168.99.101 +
-Platform: +
- Operating System:     linux +
- Architecture:     x86_64 +
-Resources: +
- CPUs:         1 +
- Memory:         995.8MiB +
-Plugins: +
- Log:         awslogs, fluentd, gcplogs, gelf, journald, json-file, logentries, splunk, syslog +
- Network:         bridge, host, macvlan, null, overlay +
- Volume:         local +
-Engine Version:     17.06.2-ce +
-Engine Labels: +
- - provider=virtualbox +
-TLS Info: +
- TrustRoot: +
------BEGIN CERTIFICATE----- +
-MIIBajCCARCgAwIBAgIUNuU4I89kxId2QXulofRKxJa9XRcwCgYIKoZIzj0EAwIw +
-EzERMA8GA1UEAxMIc3dhcm0tY2EwHhcNMTcwOTA4MTEzOTAwWhcNMzcwOTAzMTEz +
-OTAwWjATMREwDwYDVQQDEwhzd2FybS1jYTBZMBMGByqGSM49AgEGCCqGSM49AwEH +
-A0IABEqgLUbyjyNuP35aAzW+aqVB8AkghvpF5hq1KnMveHbl4Ilr+EyDjlYZkbnt +
-Gb/xmsy/tOP8uz598ZX/JlR4fZyjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMB +
-Af8EBTADAQH/MB0GA1UdDgQWBBSzoKGrN0ELfEIMsjxuYj5LAckD2jAKBggqhkjO +
-PQQDAgNIADBFAiB34DOvDtIYjJ+GzbPMGu9Dd/cJGvy7CJg1tNUG3SoOrAIhAJZ4 +
-TJBucTomFSDsj5Y/R6TfhcpXpsksk7JwYgEglu44 +
------END CERTIFICATE----- +
- +
- Issuer Subject: MBMxETAPBgNVBAMTCHN3YXJtLWNh +
- Issuer Public Key: MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAESqAtRvKPI24/floDNb5qpUHwCSCG+kXmGrUqcy94duXgiWv4TIOOVhmRue0Zv/GazL+04/y7Pn3xlf8mVHh9nA== +
-</code> +
- +
-====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>
-docker@manager1:/$ docker node ls +root@manager:~# docker inspect app_default 
-ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS +
-1f5qtolgtonqmhjk5ppwc8x1b     worker1             Ready               Active               +    { 
-kmyjdwp9ojhzje4hlw7ffhuxv     worker2             Ready               Active               +        "Name": "app_default", 
-oyszb44k8yw5btz3c1wq2ot2e     worker4             Ready               Active               +        "Id": "z62t49w18wl2mrboa92tunrhq", 
-p6jpyopzzy0zg4znegi63hzjq     worker5             Ready               Active               +        "Created": "2019-10-28T17:22:44.724040846+01:00", 
-yitkfnk99ecisrny9g3r9kfhk     worker3             Ready               Active               +        "Scope": "swarm", 
-yuwpmvtfmdxn8i7nllkyzkxkp *   manager1            Ready               Active              Leader+        "Driver": "overlay", 
 +        "EnableIPv6": false, 
 +        "IPAM": { 
 +            "Driver": "default", 
 +            "Options": null, 
 +            "Config":
 +                { 
 +                    "Subnet": "10.0.1.0/24", 
 +                    "Gateway": "10.0.1.1" 
 +                } 
 +            ] 
 +        }, 
 +        "Internal": false, 
 +        "Attachable": false, 
 +        "Ingress": false, 
 +        "ConfigFrom": { 
 +            "Network": "" 
 +        }, 
 +        "ConfigOnly": false, 
 +        "Containers": { 
 +            "2032d9eae353130e283a91bc09b65b4a84b7e8f5602a466f4ea1bd9c64e964dc":
 +                "Name": "app_visualizer.1.nbf78cn5g37dmu0fwrxt7kbrg", 
 +                "EndpointID": "d5274ff057c9d9af0288efb7f9bfed3a5ca1b3e656e265ad343f52c0b1c161f5", 
 +                "MacAddress": "02:42:0a:00:01:03", 
 +                "IPv4Address": "10.0.1.3/24", 
 +                "IPv6Address": "" 
 +            }, 
 +            "lb-app_default":
 +                "Name": "app_default-endpoint", 
 +                "EndpointID": "6afb8909d94528633e4150054311f645790280b1ab1c686c43e865ba97ec3df9", 
 +                "MacAddress": "02:42:0a:00:01:04", 
 +                "IPv4Address": "10.0.1.4/24", 
 +                "IPv6Address": "" 
 +            } 
 +        }, 
 +        "Options":
 +            "com.docker.network.driver.overlay.vxlanid_list": "4099" 
 +        }, 
 +        "Labels":
 +            "com.docker.stack.namespace": "app" 
 +        }, 
 +        "Peers":
 +            { 
 +                "Name": "377986fb7d5a", 
 +                "IP": "10.0.2.62" 
 +            } 
 +        ] 
 +    } 
 +]
 </code> </code>
  
-et que sur les 6 VM Docker, il y a 8 conteneurs,+<WRAP center round important 50%> 
 +**Important** : Notez que le réseau est **10.0.1.0/24** et la passerelle **10.0.1.1**. 
 +</WRAP>
  
-<code> +Schématiquement, la mise en place de l'application dans le Swarm est ainsi :
-docker@manager1:/$ docker service ps web +
-ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE            ERROR               PORTS +
-jkm2hapcthht        web.1               nginx:latest        worker3             Running             Running 25 minutes ago                        +
-q55eqdhr1qf1        web.2               nginx:latest        worker4             Running             Running 25 minutes ago                        +
-imqdkw4ei6gs        web.3               nginx:latest        manager1            Running             Running 25 minutes ago                        +
-k4vjd0g7ijww        web.4               nginx:latest        worker1             Running             Running 25 minutes ago                        +
-b7xbmy1npgf9        web.5               nginx:latest        worker2             Running             Running 25 minutes ago                        +
-kg3bivcg0wln        web.6               nginx:latest        worker5             Running             Running 5 minutes ago                         +
-ik3u0jfgey64        web.7               nginx:latest        worker5             Running             Running 5 minutes ago                         +
-6bw5ptw7xao8        web.8               nginx:latest        worker1             Running             Running 5 minutes ago   +
-</code>+
  
-dont deux se trouvent sur worker1 :+{{ :elearning:workbooks:docker2:docker002.png?nolink |}}
  
-<code> +Dernièrement, supprimez le stack :
-docker@manager1:/$ docker node ps worker1 +
-ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE            ERROR               PORTS +
-k4vjd0g7ijww        web.4               nginx:latest        worker1             Running             Running 26 minutes ago                        +
-6bw5ptw7xao8        web.8               nginx:latest        worker1             Running             Running 6 minutes ago        +
-</code> +
- +
-Mettez worker1 en mode d'indisponibilité en utilisant l'option **--availability drain** :+
  
 <code> <code>
-docker@manager1:/$ docker node update --availability drain worker1 +root@manager:~# docker stack ls 
-worker1 +NAME                SERVICES            ORCHESTRATOR 
-</code>+app                                   Swarm
  
-Constatez que le service web a été déplacé sur deux autres noeuds, **manager1** et **worker4** :+root@manager:~# docker stack rm app 
 +Removing service app_db 
 +Removing service app_redis 
 +Removing service app_result 
 +Removing service app_visualizer 
 +Removing service app_vote 
 +Removing service app_worker 
 +Removing network app_frontend 
 +Removing network app_backend 
 +Removing network app_default
  
-<code> +root@manager:~# docker ps -a 
-docker@manager1:/$ docker service ps web +CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                        PORTS                 NAMES 
-ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE             ERROR               PORTS +d02c6115724c        alpine              "/bin/sh"                6 days ago          Exited (0) days ago                               alpine1
-jkm2hapcthht        web.1               nginx:latest        worker3             Running             Running 29 minutes ago                         +
-q55eqdhr1qf1        web.2               nginx:latest        worker4             Running             Running 29 minutes ago                         +
-imqdkw4ei6gs        web.3               nginx:latest        manager1            Running             Running 29 minutes ago                         +
-6cv6j4tz0nk5        web.4               nginx:latest        manager1            Running             Running 33 seconds ago                         +
-k4vjd0g7ijww         \_ web.4           nginx:latest        worker1             Shutdown            Shutdown 33 seconds ago                        +
-b7xbmy1npgf9        web.5               nginx:latest        worker2             Running             Running 29 minutes ago                         +
-kg3bivcg0wln        web.              nginx:latest        worker5             Running             Running 9 minutes ago                          +
-ik3u0jfgey64        web.7               nginx:latest        worker5             Running             Running 9 minutes ago                          +
-wht3r8c9wga6        web.8               nginx:latest        worker4             Running             Running 33 seconds ago                         +
-6bw5ptw7xao8         \_ web.8           nginx:latest        worker1             Shutdown            Shutdown 33 seconds ago +
 </code> </code>
  
-====3.10 Supprimer un Service===+-----
  
-Pour supprimer un service il convient d'utiliser la commande **docker service rm** +Copyright © 2024 Hugh Norris.
- +
-<code> +
-docker@manager1:/$ docker service rm web +
-web +
-</code> +
- +
-<code> +
-docker@manager1:/$ docker service ls +
-ID                  NAME                MODE                REPLICAS            IMAGE               PORTS +
-</code> +
- +
-<code> +
-docker@manager1:/$ docker service inspect web +
-[] +
-Status: Error: no such service: web, Code: 1 +
-</code> +
- +
-Sortez de manager1 et démarrez le serveur VNC dans la machine virtuelle **debian9** en tant que **trainee** : +
- +
-<code> +
-docker@manager1:/$ exit +
-root@debian9:~# exit +
-trainee@debian9:~$ vncserver +
- +
-New 'X' desktop is debian9.i2tch.loc:+
- +
-Starting applications specified in /home/trainee/.vnc/xstartup +
-Log file is /home/trainee/.vnc/debian9.i2tch.loc:1.log +
-</code> +
- +
-====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. Ce processus 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 © 2021 Hugh NORRIS +
-</div> +
-</html>+
Menu