Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
elearning:workbooks:docker3:drf05 [2021/11/21 11:42] – created admin | elearning:workbooks:docker3:drf05 [2024/02/21 13:40] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
~~PDF: | ~~PDF: | ||
- | Version : **2021.01** | + | Version : **2024.01** |
Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
- | ======DOF606 - Docker | + | ======DOF606 - Gestion du Réseau Overlay avec Docker |
=====Contenu du Module===== | =====Contenu du Module===== | ||
- | * **DOF606 - Docker | + | * **DOF606 - Gestion du Réseau Overlay avec Docker |
* Contenu du Module | * Contenu du Module | ||
- | * LAB #1 - Docker | + | * L' |
- | * 1.1 - Installation | + | * LAB #1 - Gestion du Réseau overlay |
- | * 1.2 - Utiliser docker-compose | + | * 1.1 - Création d'un Réseau overlay |
- | * LAB #2 - Docker Machine | + | * 1.2 - Création |
- | * 2.1 - Présentation | + | * 1.3 - Déplacer le Service vers un autre Réseau overlay |
- | * 2.2 - Création | + | * 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' | + | * LAB #2 - Gestion |
- | * 2.5 - Se connecter à une VM Docker | + | * 2.1 - 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 | + | |
- | * 3.6 - Démarrer un Service | + | |
- | * 3.7 - Augmentation et Réduction du Service | + | |
- | * 3.8 - Consulter le Statut d'un Nœud | + | |
- | * 3.9 - Haute Disponibilité | + | |
- | * 3.10 - Supprimer un Service | + | |
- | * 3.11 - Sauvegarder Docker Swarm | + | |
- | * 3.12 - Restaurer | + | |
- | =====LAB #1 - Docker | + | =====L' |
- | 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'approche réseau |
- | Ce fichier, appelé par la commande **docker-compose build** commence avec un mot clef **image** ou **build** selon que l' | + | * Sandbox, |
+ | * contient | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
- | Une fois totalement construite, l' | + | {{ : |
- | De cette façon il est possible de démarrer l' | + | =====LAB #1 - Gestion du Réseau overlay===== |
- | ====1.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' |
- | Récupérez docker-compose | + | 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' |
+ | |||
+ | Le trafic lié à la gestion des services swarm est crypté par défaut | ||
- | <code> | + | <WRAP center round important 50%> |
- | root@debian9:~# curl -L " | + | **ATTENTION** |
- | % Total % Received % Xferd Average Speed | + | </WRAP> |
- | | + | |
- | 100 | + | |
- | 100 5140k 100 5140k 0 | + | |
- | root@debian9: | + | Commencez par re-créer un swarm en utilisant les machines virtuelles |
- | </ | + | |
- | + | ||
- | Rendez | + | |
< | < | ||
- | root@debian9:~# ls -l / | + | root@debian11:~# ssh -l trainee 10.0.2.62 |
- | -rw-r--r-- 1 root staff 5263681 Jan | + | The authenticity of host ' |
- | root@debian9:~# chmod u+x / | + | ECDSA key fingerprint is SHA256:sEfHBv9azmK60cjqF/aJgUc9jg56slNaZQdAUcvBOvE. |
- | </ | + | Are you sure you want to continue connecting (yes/no/[fingerprint])? |
+ | Warning: Permanently added ' | ||
+ | trainee@10.0.2.62' | ||
+ | Linux manager.i2tch.loc 4.9.0-8-amd64 | ||
- | Avant de commencer, installez l' | + | 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 / | ||
- | < | + | Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent |
- | root@debian9: | + | permitted by applicable law. |
- | Reading package lists... Done | + | Last login: Sun Jul 17 08:27:29 2022 from 10.0.2.1 |
- | Building dependency tree | + | trainee@manager: |
- | Reading state information... Done | + | Mot de passe : fenestros |
- | The following NEW packages will be installed: | + | root@manager: |
- | tree | + | |
- | 0 upgraded, 1 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:// | + | |
- | 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 .../ | + | |
- | Unpacking tree (1.7.0-3) ... | + | |
- | Processing triggers for man-db (2.7.0.2-5) ... | + | |
- | Setting up tree (1.7.0-3) ... | + | |
- | </ | + | |
- | ====1.2 - Utiliser | + | root@manager: |
+ | Node left the swarm. | ||
+ | root@manager: | ||
+ | Swarm initialized: | ||
- | ===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 ' |
- | * production | + | root@manager:~# exit |
- | + | trainee@manager:~# exit | |
- | afin d'utiliser deux configurations différentes selon l' | + | |
- | + | ||
- | Commencez par créer l' | + | |
- | + | ||
- | < | + | |
- | root@debian9: | + | |
- | root@debian9: | + | |
- | root@debian9: | + | |
- | root@debian9: | + | |
- | root@debian9:~# touch MyApp/ | + | |
- | root@debian9:~# touch MyApp/ | + | |
</ | </ | ||
- | Utilisez l' | + | Connectez-vous au **worker1** |
< | < | ||
- | root@debian9:~# cd MyApp | + | root@manager:~# ssh -l trainee 10.0.2.63 |
- | root@debian9:~/MyApp# tree | + | The authenticity of host ' |
- | . | + | 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' |
- | │ ├── 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 | + | |
- | | + | |
- | 5 directories, | + | 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 / | ||
- | Ce projet comporte la structure suivante | + | Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent |
+ | permitted by applicable law. | ||
+ | Last login: Sun Mar 21 16:34:26 2021 from 10.0.2.11 | ||
+ | trainee@worker1: | ||
+ | Mot de passe : fenestros | ||
+ | root@worker1: | ||
- | * **common** | + | root@worker1: |
- | * La configuration commune aux deux environnements sera placée dans le fichier **MyApp/ | + | Node left the swarm. |
- | * **development** | + | |
- | * La configuration spécifique à l' | + | |
- | * **production** | + | |
- | * La configuration spécifique à l' | + | |
- | Commencez par la création des deux Dockerfile pour **development** et **production**. Afin de garder l' | + | root@worker1:~# docker swarm join --token SWMTKN-1-23d7n1fkkk9rvlhty106q9390bfpf9daljjguq3s807le6c5qs-e0s1yqsajvmi7s8t9l9mw48ao 10.0.2.62: |
- | + | This node joined a swarm as a worker. | |
- | < | + | |
- | root@debian9:~/MyApp# vi development/ | + | |
- | root@debian9:~/MyApp# cat development/ | + | root@worker1:~# exit |
- | FROM tianon/true | + | déconnexion |
- | VOLUME ["/ | + | trainee@worker1: |
- | ADD index.html / | + | déconnexion |
+ | Connection to 10.0.2.63 closed. | ||
- | root@debian9:~/MyApp# cp development/ | + | root@manager:~# |
</ | </ | ||
- | Créez maintenant le fichier | + | Connectez-vous au **worker2** : |
< | < | ||
- | root@debian9:~/MyApp# vi common/docker-compose.yml | + | root@manager:~# ssh -l trainee 10.0.2.64 |
+ | The authenticity of host ' | ||
+ | ECDSA key fingerprint is SHA256: | ||
+ | Are you sure you want to continue connecting (yes/no)? yes | ||
+ | Warning: Permanently added ' | ||
+ | trainee@10.0.2.64' | ||
+ | Linux worker2.i2tch.loc 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 | ||
- | root@debian9: | + | The programs included with the Debian GNU/Linux system are free software; |
- | web: | + | the exact distribution terms for each program are described in the |
- | | + | individual files in /usr/ |
- | ports: | + | |
- | - 8082:80 | + | |
- | </code> | + | |
- | Les deux fichiers **MyApp/development/ | + | 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: | ||
+ | Mot de passe : fenestros | ||
+ | root@worker2:~# | ||
- | < | + | root@worker2:~# docker |
- | root@debian9:~/MyApp# vi development/ | + | Node left the swarm. |
- | + | ||
- | root@debian9: | + | |
- | web: | + | |
- | extends: | + | |
- | file: ../ | + | |
- | service: web | + | |
- | volumes_from: | + | |
- | - content | + | |
- | content: | + | root@worker2:~# docker |
- | build: content | + | This node joined a swarm as a worker. |
- | + | ||
- | root@debian9:~/MyApp# cp development/ | + | |
- | </ | + | |
- | + | ||
- | Éditez maintenant les deux fichiers index.html : | + | |
- | + | ||
- | < | + | |
- | root@debian9: | + | |
- | root@debian9:~/MyApp# cat development/ | + | root@worker2:~# exit |
- | < | + | déconnexion |
- | < | + | |
- | < | + | |
- | </ | + | |
- | </ | + | |
- | root@debian9:~/MyApp# vi production/ | + | trainee@worker2:~$ exit |
+ | déconnexion | ||
+ | Connection to 10.0.2.64 closed. | ||
- | root@debian9:~/MyApp# cat production/ | + | root@manager:~# |
- | < | + | |
- | < | + | |
- | < | + | |
- | </ | + | |
- | </ | + | |
</ | </ | ||
- | Placez-vous dans le sous-répertoire **development** et exécutez la commande **docker-compose up -d** : | + | Vérifiez l' |
< | < | ||
- | root@debian9:~/ | + | root@manager:~# docker |
- | Creating development_content_1... | + | ID HOSTNAME |
- | Building content... | + | b85hxlixbr1mh1txd1hrfe4us * |
- | Step 1/3 : FROM tianon/true | + | 4sui75vvdhmet4qvt0zbvzlzl |
- | ---> 1298b2036003 | + | lbjtg5o9kw3x6xg7frm07jfuw |
- | Step 2/3 : VOLUME / | + | root@manager:~# docker node ls --filter role=manager |
- | ---> Running in 8619de833add | + | ID HOSTNAME |
- | ---> 694e4f111996 | + | b85hxlixbr1mh1txd1hrfe4us * |
- | Removing intermediate container 8619de833add | + | root@manager: |
- | Step 3/3 : ADD index.html / | + | ID HOSTNAME |
- | ---> f6fabac6703b | + | 4sui75vvdhmet4qvt0zbvzlzl |
- | Removing intermediate container a9bec35dba66 | + | lbjtg5o9kw3x6xg7frm07jfuw |
- | Successfully built f6fabac6703b | + | |
- | Successfully tagged development_content: | + | |
- | Creating development_web_1... | + | |
</ | </ | ||
- | La commande | + | Vérifiez la présence du réseau overlay |
- | + | ||
- | Les options de la commande | + | |
< | < | ||
- | root@debian9:~# docker-compose --help | + | root@manager:~# docker |
- | Fast, isolated development environments using Docker. | + | NETWORK ID NAME DRIVER |
+ | 4edb7186dcc9 | ||
+ | d4c9b0c9437a | ||
+ | f3cb3bc3c581 | ||
+ | r8htcvc8oxmz | ||
+ | de563e30d473 | ||
+ | </ | ||
- | Usage: | + | <WRAP center round info 50%> |
- | docker-compose [options] [COMMAND] [ARGS...] | + | **Info** |
- | | + | </ |
- | Options: | + | <WRAP center round tip 50%> |
- | | + | **Best Practice** |
- | --version | + | </ |
- | -f, --file FILE | + | |
- | -p, --project-name NAME | + | |
- | Commands: | + | ====1.1 |
- | 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 | + | |
- | up Create and start containers | + | |
- | </ | + | |
- | Vérifiez que l' | + | A partir du Manager, créez un réseau de type overlay appelé |
< | < | ||
- | root@debian9:~/ | + | root@manager:~# docker |
- | REPOSITORY | + | j57jhtug4kjxp22ai1y664lqr |
- | development_content | + | root@manager: |
- | ... | + | NETWORK |
+ | dde514eea83f | ||
+ | d4c9b0c9437a | ||
+ | f3cb3bc3c581 | ||
+ | r8htcvc8oxmz | ||
+ | j57jhtug4kjx | ||
+ | de563e30d473 | ||
</ | </ | ||
- | Constatez la présence des deux conteneurs | + | ====1.2 - Création d'un Service==== |
+ | |||
+ | Créez un service nginx qui utilise le réseau | ||
< | < | ||
- | root@debian9:~/ | + | root@manager:~# docker |
- | CONTAINER ID IMAGE | + | fpydgix3e1rc1qum72gvwcb7f |
- | 6955516dceff | + | overall progress: 5 out of 5 tasks |
- | 9a1876d7a145 | + | 1/5: running |
- | ... | + | 2/5: running |
+ | 3/5: running | ||
+ | 4/5: running | ||
+ | 5/5: running | ||
+ | verify: Service converged | ||
</ | </ | ||
- | Utilisez maintenant lynx pour consultez | + | <WRAP center round info 50%> |
- | + | **Info** : Le service publie le port 80 qui est visible de l' | |
- | <code> | + | </WRAP> |
- | root@debian9: | + | |
- | This is the development environement | + | |
+ | Vérifiez que le service fonctionne avant de poursuivre : | ||
- | root@debian9:~/MyApp/development# | + | < |
+ | root@manager:~# docker service ls | ||
+ | ID NAME MODE REPLICAS | ||
+ | fpydgix3e1rc | ||
</ | </ | ||
- | Arrêtez docker-compose | + | Consultez maintenant les détails du service |
< | < | ||
- | root@debian9:~/ | + | root@manager:~# docker |
- | Stopping development_web_1... | + | [ |
- | root@debian9: | + | { |
- | CONTAINER | + | " |
- | 6955516dceff | + | " |
- | 9a1876d7a145 | + | " |
- | ... | + | |
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | }, | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | }, | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | } | ||
+ | ] | ||
</ | </ | ||
- | Placez-vous maintenant dans le sous-répertoire | + | <WRAP center round important 50%> |
+ | **Important** : Notez ici les informations concernant les ports et les Endpoints utilisés par le service. | ||
+ | </ | ||
- | < | + | ====1.3 - Déplacer le Service vers un autre Réseau overlay==== |
- | root@debian9: | + | |
- | root@debian9: | + | |
- | Creating production_content_1... | + | |
- | Building content... | + | |
- | Step 1/3 : FROM tianon/ | + | |
- | ---> 1298b2036003 | + | |
- | Step 2/3 : VOLUME / | + | |
- | | + | |
- | | + | |
- | Step 3/3 : ADD index.html / | + | |
- | | + | |
- | Removing intermediate container 18af8bcb48ce | + | |
- | Successfully built 61bcd73aff6e | + | |
- | Successfully tagged production_content: | + | |
- | Creating production_web_1... | + | |
- | </ | + | |
- | Notez la création du conteneur | + | Consultez le réseau overlay |
< | < | ||
- | root@debian9:~/ | + | root@manager:~# docker |
- | CONTAINER ID IMAGE | + | [ |
- | 8a2c7346a5db | + | { |
- | 5fde5e7cbd47 | + | |
- | 6955516dceff | + | " |
- | 9a1876d7a145 | + | " |
- | ... | + | " |
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | }, | ||
+ | " | ||
+ | "Attachable": | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | "lb-nginx-net": { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | "Options": { | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | ] | ||
</ | </ | ||
- | |||
- | En étant dans le contexte **production**, | ||
< | < | ||
- | root@debian9:~/ | + | root@worker1:~# docker |
- | Name Command | + | [ |
- | --------------------------------------------------------------------------- | + | { |
- | production_content_1 | + | |
- | production_web_1 | + | " |
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | "lb-nginx-net": { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | ] | ||
</ | </ | ||
- | |||
- | De même en utilisant la même commande dans le répertoire **development**, | ||
< | < | ||
- | root@debian9:~/ | + | root@worker2:~# docker inspect nginx-net |
- | root@debian9:~/ | + | [ |
- | Name | + | { |
- | ------------------------------------------------------------- | + | " |
- | development_content_1 | + | " |
- | development_web_1 | + | " |
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | "Name": " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | "lb-nginx-net": { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | ] | ||
</ | </ | ||
- | Utilisez maintenant lynx pour consultez | + | <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** : | ||
< | < | ||
- | root@debian9:~/ | + | root@manager:~# docker network create |
- | This is the production environement | + | aez5huut9hd472qmldzf2tsud |
+ | </code> | ||
+ | Déplacez le service **my-nginx** vers le réseau **nginx-net-2** : | ||
- | root@debian9:~/MyApp/development# | + | < |
+ | 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 | ||
</ | </ | ||
- | ===Installer Wordpress avec Docker Compose=== | + | Vérifiez que le service fonctionne avant de poursuivre |
- | + | ||
- | Créez maintenant | + | |
< | < | ||
- | root@debian9:~/ | + | root@manager:~# docker service ls |
- | root@debian9:~# mkdir wordpress1 | + | ID NAME MODE REPLICAS |
+ | fpydgix3e1rc | ||
</ | </ | ||
- | Placez-vous | + | Vérifiez qu' |
< | < | ||
- | root@debian9:~# cd wordpress1 | + | root@manager:~# docker |
- | root@debian9: | + | [ |
- | root@debian9:~/ | + | { |
- | version: "3.3" | + | " |
- | + | " | |
- | services: | + | " |
- | db: | + | " |
- | image: mysql:5.7 | + | " |
- | | + | " |
- | - db_data:/ | + | " |
- | | + | " |
- | | + | " |
- | | + | " |
- | | + | { |
- | | + | " |
- | | + | " |
- | + | } | |
- | wordpress: | + | ] |
- | | + | }, |
- | - db | + | "Internal": false, |
- | | + | " |
- | | + | " |
- | | + | " |
- | | + | " |
- | | + | }, |
- | | + | " |
- | | + | " |
- | | + | " |
- | | + | " |
- | volumes: | + | }, |
- | | + | " |
+ | | ||
+ | ] | ||
</ | </ | ||
- | Exécutez la commande docker-compose | + | Vérifiez maintenant que les conteneurs se trouvent dans le réseau **nginx-net-2** |
< | < | ||
- | root@debian9:~/wordpress1# docker-compose up -d | + | root@manager:~# docker |
+ | [ | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | ] | ||
</ | </ | ||
- | Vérifiez que le Wordpress fonctionne | + | Supprimez maintenant |
< | < | ||
- | root@debian9:~/wordpress1# lynx --dump http:// | + | root@manager:~# docker service rm my-nginx |
- | | + | my-nginx |
- | | + | |
- | | + | root@manager:~# docker |
- | + | nginx-net | |
- | root@debian9:~# docker | + | nginx-net-2 |
- | CONTAINER ID IMAGE | + | |
- | 29afa2a7fdb5 | + | |
- | ... | + | |
- | + | ||
- | root@debian9: | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | + | ||
- | root@debian9: | + | |
- | | + | |
- | | + | |
- | + | ||
- | | + | |
</ | </ | ||
- | =====LAB #2 - Docker Machine===== | + | ====1.4 - DNS container discovery==== |
- | ====2.1 - Présentation==== | + | Le daemon Docker exécute un server DNS embarqué à l' |
- | Docker Machine est un outil qui vous permet d' | + | Pour que le **DNS container discovery** fonctionne, les ports suivants doivent être ouverts |
- | 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 " | + | * 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 |
< | < | ||
- | root@debian9:~# curl -L https:// | + | root@manager:~# docker |
+ | hrs25w4l951kkickhj6262mjg | ||
</ | </ | ||
- | ====2.2 | + | <WRAP center round important 50%> |
+ | **Important** : Notez que le **NETWORK-ID** ici est **hrs25w4l951kkickhj6262mjg**. | ||
+ | </ | ||
- | La création d'une machine se fait simplement en utilisant la commande | + | Sur le Manager, démarrez un conteneur interactif appelé |
- | ^ Fournisseur ^ driver ^ | + | < |
- | | [[https:// | + | root@manager:~# docker |
- | | [[https:// | + | Unable to find image ' |
- | | [[https:// | + | latest: Pulling from library/alpine |
- | | [[https:// | + | 89d9c30c1d48: Pull complete |
- | | [[http:// | + | Digest: sha256:c19173c5ada610a5989151111163d28a67368362762534d8a8121ce95cf2bd5a |
- | | [[https:// | + | Status: Downloaded newer image for alpine:latest |
- | | [[https:// | + | / # |
- | | [[https:// | + | </code> |
- | | [[https:// | + | |
- | | [[https:// | + | |
- | | [[https:// | + | |
- | | [[https:// | + | |
- | | [[https:// | + | |
- | Commencez par installer Oracle VirtualBox: | + | Listez les réseaux disponibles sur **Worker1** |
< | < | ||
- | root@debian9:~/wordpress# cd ~ | + | root@worker1:~# docker network ls |
- | root@debian9: | + | NETWORK ID NAME DRIVER |
+ | 3fe43b514f9d | ||
+ | ee22b3e623ca | ||
+ | f3cb3bc3c581 | ||
+ | r8htcvc8oxmz | ||
+ | de563e30d473 | ||
</ | </ | ||
- | Créez | + | <WRAP center round important 50%> |
+ | **Important** : Notez que le réseau **test-net** n'a pas été créé. | ||
+ | </ | ||
+ | |||
+ | Démarrez | ||
< | < | ||
- | root@debian9:~# docker-machine create | + | root@worker1:~# docker |
- | Creating CA: / | + | Unable to find image ' |
- | Creating client certificate: /root/ | + | latest: Pulling from library/alpine |
- | Running pre-create checks... | + | 89d9c30c1d48: |
- | (manager1) Image cache directory does not exist, creating it at / | + | Digest: sha256: |
- | (manager1) No default Boot2Docker ISO found locally, downloading the latest release... | + | Status: Downloaded newer image for alpine: |
- | (manager1) Latest release for github.com/ | + | 5734e84cd460cdd33ce90970d98a96837a0305832a86fc4d86be38aecf51b23b |
- | (manager1) Downloading / | + | |
- | (manager1) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100% | + | |
- | Creating machine... | + | |
- | (manager1) Copying / | + | |
- | (manager1) Creating VirtualBox VM... | + | |
- | (manager1) Creating SSH key... | + | |
- | (manager1) Starting the VM... | + | |
- | (manager1) Check network to re-create if needed... | + | |
- | (manager1) Found a new host-only adapter: " | + | |
- | (manager1) Waiting | + | |
- | 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 | + | |
</ | </ | ||
- | Les options de la commande **docker-machine** sont : | + | Saisissez |
< | < | ||
- | root@debian9:~# docker-machine --help | + | root@worker1:~# docker |
- | Usage: docker-machine [OPTIONS] COMMAND [arg...] | + | NETWORK ID NAME DRIVER |
+ | 3fe43b514f9d | ||
+ | ee22b3e623ca | ||
+ | f3cb3bc3c581 | ||
+ | r8htcvc8oxmz | ||
+ | de563e30d473 | ||
+ | hrs25w4l951k | ||
+ | </ | ||
- | Create and manage machines running Docker. | + | <WRAP center round important 50%> |
+ | **Important** : Notez que le réseau **test-net**, | ||
+ | </ | ||
- | Version: 0.12.2, build 9371605 | + | Listez les réseaux disponibles sur **Worker2** |
- | Author: | + | <code> |
- | Docker Machine Contributors - <https:// | + | root@worker2:~# docker |
+ | NETWORK ID NAME DRIVER | ||
+ | ff7308310f60 | ||
+ | 0ce1d8369c29 | ||
+ | f3cb3bc3c581 | ||
+ | r8htcvc8oxmz | ||
+ | de563e30d473 | ||
+ | </code> | ||
- | Options: | + | <WRAP center round important 50%> |
- | | + | **Important** |
- | --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 ' | + | |
- | </code> | + | |
- | Créez maintenant 5 travailleurs - **worker1** jusqu' | + | Attachez vous au conteneur |
< | < | ||
- | root@debian9:~# docker-machine create --driver virtualbox worker1 | + | root@worker1:~# docker |
- | Running pre-create checks... | + | CONTAINER ID IMAGE |
- | Creating machine... | + | ce9097b864dc |
- | (worker1) Copying | + | |
- | (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 | + | |
- | </ | + | |
- | < | + | root@worker1:~# docker |
- | 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.2: seq=0 ttl=64 time=1.874 ms |
- | ... | + | 64 bytes from 10.0.2.2: seq=1 ttl=64 time=1.669 ms |
- | root@debian9: | + | |
- | ... | + | --- alpine1 ping statistics --- |
+ | 2 packets transmitted, | ||
+ | round-trip min/avg/max = 1.669/1.771/1.874 ms | ||
+ | / # | ||
</ | </ | ||
- | Les options de la sous-commande | + | Retournez dans la VM **Manager** et essayez |
< | < | ||
- | root@debian9:~# docker-machine create --help | + | root@manager:~# docker |
- | 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 ' | + | 2 packets transmitted, |
+ | round-trip min/avg/max = 0.666/ | ||
+ | / # | ||
+ | </ | ||
- | Options: | + | Créez ensuite le conteneur **alpine3** sur le **Worker2** essayez de contacter le conteneur **alpine1** |
- | + | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | </ | + | |
- | ====2.3 | + | < |
+ | root@worker2: | ||
+ | Unable to find image ' | ||
+ | latest: Pulling from library/ | ||
+ | c9b1b535fdd9: | ||
+ | Digest: sha256: | ||
+ | Status: Downloaded newer image for alpine: | ||
+ | / # | ||
- | Pour lister les VM Docker ainsi que leurs états, il convient d' | + | / # 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.2: seq=1 ttl=64 time=1.684 ms | ||
- | < | + | --- alpine1 ping statistics --- |
- | root@debian9: | + | 2 packets transmitted, |
- | NAME | + | round-trip min/avg/max = 0.642/1.163/1.684 ms |
- | manager1 | + | / # exit |
- | worker1 | + | |
- | worker2 | + | |
- | worker3 | + | |
- | worker4 | + | |
- | worker5 | + | |
</ | </ | ||
- | ====2.4 - Obtenir l' | + | Arrêtez maintenant le conteneur |
- | + | ||
- | Une autre façon d' | + | |
< | < | ||
- | root@debian9:~# docker-machine ip manager1 | + | root@worker1: |
- | 192.168.99.100 | + | alpine2 |
- | root@debian9: | + | |
- | 192.168.99.101 | + | |
- | root@debian9: | + | |
- | 192.168.99.102 | + | |
- | root@debian9: | + | |
- | 192.168.99.103 | + | |
- | root@debian9: | + | |
- | 192.168.99.104 | + | |
- | root@debian9:~# docker-machine ip worker5 | + | |
- | 192.168.99.105 | + | |
</ | </ | ||
- | ====2.5 - Se connecter à une VM Docker==== | + | Saisissez |
- | + | ||
- | Pour se connecter à une VM Docker, il convient d' | + | |
< | < | ||
- | root@debian9:~# docker-machine ssh manager1 | + | root@worker1:~# docker |
- | ## | + | NETWORK ID NAME DRIVER |
- | ## ## ## == | + | 3bb80f391804 |
- | ## ## ## ## ## === | + | ee22b3e623ca |
- | /""""""""""""""""" | + | f3cb3bc3c581 |
- | ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~ | + | r8htcvc8oxmz |
- | | + | de563e30d473 |
- | | + | |
- | \____\_______/ | + | |
- | _ | + | |
- | | |__ | + | |
- | | '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__| | + | |
- | | |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < | + | |
- | |_.__/ \___/ \___/ \__|_____\__, | + | |
- | 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: | + | |
</ | </ | ||
- | <WRAP center round important> | + | <WRAP center round important |
- | **Important** | + | **Important** |
</ | </ | ||
- | Installez maintenant | + | Supprimez |
< | < | ||
- | root@debian9:~# apt install mlocate | + | root@worker1:~# docker container rm alpine2 |
- | ... | + | alpine2 |
</ | </ | ||
- | Ayant été créées par root, les VM Docker ainsi que leurs fichiers associés sont stockés dans le répertoire | + | Arrêtez |
< | < | ||
- | root@debian9: | + | / # exit |
- | root@debian9: | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | </ | + | |
- | =====LAB | + | root@manager: |
+ | alpine1 | ||
- | ====3.1 | + | root@manager: |
+ | NETWORK ID NAME DRIVER | ||
+ | a604e7db6f95 | ||
+ | d4c9b0c9437a | ||
+ | f3cb3bc3c581 | ||
+ | jxu667wzmj2u | ||
+ | de563e30d473 | ||
+ | 518l09lcjhsp | ||
- | 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 |
- | + | test-net | |
- | ====3.2 - Initialiser Docker Swarm==== | + | |
- | + | ||
- | Pour initialiser Docker swarm, il convient d' | + | |
- | + | ||
- | < | + | |
- | root@debian9:~# docker-machine ssh manager1 | + | |
- | docker@manager1: | + | |
- | Swarm initialized: | + | |
- | + | ||
- | To add a worker to this swarm, run the following command: | + | |
- | + | ||
- | docker swarm join --token SWMTKN-1-5bd9w9tapfqmd41f2psqdkoqwfo48fqsznnalk2slc28vlp6uh-004kp8y71m09nd7p8ft7ldku0 192.168.99.100: | + | |
- | + | ||
- | To add a manager to this swarm, run ' | + | |
</ | </ | ||
- | 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 |
- | + | ||
- | Consultez le statut | + | |
< | < | ||
- | docker@manager1:~$ docker | + | root@manager:~# docker network rm ingress |
- | ID HOSTNAME | + | WARNING! Before removing the routing-mesh network, make sure all the nodes in your swarm run the same docker |
- | yuwpmvtfmdxn8i7nllkyzkxkp * | + | Are you sure you want to continue? [y/N] y |
+ | ingress | ||
</ | </ | ||
- | A un instant t il ne peut y avoir q'un seul **Leader**. Il est possible de créer d' | + | 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 | + | |
< | < | ||
- | docker@manager1:~$ docker | + | root@manager:~# docker |
- | To add a manager to this swarm, run the following command: | + | 44ozn3vtg23zkksrvloxuulcl |
- | | + | root@manager: |
+ | NETWORK ID NAME DRIVER | ||
+ | 24be8a0f0ef5 | ||
+ | d4c9b0c9437a | ||
+ | f3cb3bc3c581 | ||
+ | 44ozn3vtg23z | ||
+ | de563e30d473 | ||
</ | </ | ||
- | ====3.4 - Rejoindre | + | Créez de nouveau |
- | + | ||
- | Rejoignez les 5 machines travailleurs à swarm en utilisant le token **worker** : | + | |
< | < | ||
- | docker@worker1:~$ docker | + | root@manager:~# docker |
- | This node joined a swarm as a worker. | + | gp1iozmbi25dx3skn00m6suoz |
- | </code> | + | 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 | ||
- | < | + | root@manager:~# docker |
- | docker@worker2:~$ docker | + | ID NAME MODE REPLICAS |
- | This node joined a swarm as a worker. | + | gp1iozmbi25d |
- | </code> | + | |
- | < | + | root@manager:~# docker |
- | docker@worker3:~$ docker | + | ID NAME IMAGE |
- | This node joined | + | upmbwmtr76cm |
+ | qz6p1li7zmef | ||
+ | me50mkhd11yk | ||
+ | sctjud70ihkl | ||
+ | kql9qx3phb73 | ||
</ | </ | ||
- | < | + | Consultez les informations concernant le service **my-nginx** |
- | docker@worker4: | + | |
- | This node joined a swarm as a worker. | + | |
- | </ | + | |
< | < | ||
- | docker@worker5:~$ docker | + | root@manager:~# docker |
- | This node joined a swarm as a worker. | + | [ |
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | }, | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | } | ||
+ | ] | ||
</ | </ | ||
- | 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 |
- | + | ||
- | L' | + | |
< | < | ||
- | docker@manager1:~$ docker | + | root@manager:~# docker |
- | ID HOSTNAME | + | [ |
- | 1f5qtolgtonqmhjk5ppwc8x1b | + | { |
- | kmyjdwp9ojhzje4hlw7ffhuxv | + | " |
- | oyszb44k8yw5btz3c1wq2ot2e | + | " |
- | p6jpyopzzy0zg4znegi63hzjq | + | " |
- | yitkfnk99ecisrny9g3r9kfhk | + | " |
- | yuwpmvtfmdxn8i7nllkyzkxkp * | + | " |
+ | " | ||
+ | " | ||
+ | | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | ] | ||
</ | </ | ||
- | Notez que vous ne pouvez pas utiliser cette commande à partir d'un travailleur | + | Supprimez maintenant le service **my-nginx** |
< | < | ||
- | docker@worker5:~$ docker | + | root@manager:~# docker |
- | 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 |
</ | </ | ||
- | ====3.5 - Consulter les Informations | + | =====LAB #2 - Gestion d'une Architecture |
- | Il est possible de visualiser les informations concernant le swarm en utilisant la commande | + | Vous allez mettre |
- | < | + | {{ :elearning:workbooks:debian:6:avance:app.png? |
- | docker@manager1:~$ docker info | + | |
- | ... | + | |
- | Swarm: active | + | |
- | | + | |
- | Is Manager: true | + | |
- | | + | |
- | | + | |
- | Nodes: 6 | + | |
- | | + | |
- | Task History Retention Limit: 5 | + | |
- | | + | |
- | Snapshot Interval: 10000 | + | |
- | Number of Old Snapshots to Retain: 0 | + | |
- | Heartbeat Tick: 1 | + | |
- | Election Tick: 3 | + | |
- | | + | |
- | Heartbeat Period: 5 seconds | + | |
- | CA Configuration: | + | |
- | Expiry Duration: 3 months | + | |
- | Force Rotate: 0 | + | |
- | Root Rotation In Progress: false | + | |
- | Node Address: 192.168.99.100 | + | |
- | | + | |
- | 192.168.99.100: | + | |
- | ... | + | |
- | </ | + | |
- | <WRAP center round important> | + | Dans cette application le conteneur |
- | **Important** - Quand le moteur Docker est en mode swarm, les noeuds | + | |
- | </ | + | |
- | ====3.6 - Démarrer un Service==== | + | {{ : |
- | Dans cet exemple, nous allons démarrer | + | 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. |
- | | + | L' |
- | | + | |
- | | + | |
- | < | + | {{ :elearning:workbooks: |
- | 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. | + | |
- | </ | + | |
- | Pour consulter l' | + | ====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 | ||
< | < | ||
- | docker@manager1:~$ docker | + | root@manager:~# docker |
- | ID | + | ID |
- | 4xtuwgbvr17l | + | b85hxlixbr1mh1txd1hrfe4us |
+ | 4sui75vvdhmet4qvt0zbvzlzl | ||
+ | lbjtg5o9kw3x6xg7frm07jfuw | ||
</ | </ | ||
- | Ce service fonctionne dans des conteneurs Docker | + | Créez maintenant le fichier **docker-stack.yml** |
< | < | ||
- | docker@manager1:~$ docker | + | root@manager:~# vi docker-stack.yml |
- | ID NAME IMAGE | + | |
- | jkm2hapcthht | + | |
- | q55eqdhr1qf1 | + | |
- | imqdkw4ei6gs | + | |
- | k4vjd0g7ijww | + | |
- | b7xbmy1npgf9 | + | |
- | </ | + | |
- | <WRAP center round important> | + | root@manager: |
- | **Important** | + | version: " |
- | </ | + | services: |
- | Pour constater le lancement du daemon nginx, lancez la commande **docker ps** sur la machine **manager1** | + | redis: |
+ | image: redis: | ||
+ | networks: | ||
+ | - frontend | ||
+ | deploy: | ||
+ | replicas: 1 | ||
+ | update_config: | ||
+ | parallelism: | ||
+ | delay: 10s | ||
+ | restart_policy: | ||
+ | condition: on-failure | ||
+ | db: | ||
+ | image: postgres: | ||
+ | environment: | ||
+ | POSTGRES_USER: | ||
+ | POSTGRES_PASSWORD: | ||
+ | volumes: | ||
+ | - db-data:/ | ||
+ | networks: | ||
+ | - backend | ||
+ | deploy: | ||
+ | placement: | ||
+ | constraints: | ||
+ | vote: | ||
+ | image: dockersamples/ | ||
+ | ports: | ||
+ | - 5000:80 | ||
+ | networks: | ||
+ | - frontend | ||
+ | depends_on: | ||
+ | - redis | ||
+ | deploy: | ||
+ | replicas: 2 | ||
+ | update_config: | ||
+ | parallelism: | ||
+ | restart_policy: | ||
+ | condition: on-failure | ||
+ | result: | ||
+ | image: dockersamples/ | ||
+ | ports: | ||
+ | - 5001:80 | ||
+ | networks: | ||
+ | - backend | ||
+ | depends_on: | ||
+ | - db | ||
+ | deploy: | ||
+ | replicas: 1 | ||
+ | update_config: | ||
+ | parallelism: | ||
+ | delay: 10s | ||
+ | restart_policy: | ||
+ | condition: on-failure | ||
- | < | + | worker: |
- | docker@manager1:~$ docker ps | + | |
- | CONTAINER ID IMAGE | + | networks: |
- | 4107cb687eda | + | - frontend |
+ | - backend | ||
+ | depends_on: | ||
+ | - db | ||
+ | - redis | ||
+ | deploy: | ||
+ | mode: replicated | ||
+ | replicas: 1 | ||
+ | labels: [APP=VOTING] | ||
+ | restart_policy: | ||
+ | | ||
+ | | ||
+ | max_attempts: | ||
+ | window: 120s | ||
+ | placement: | ||
+ | constraints: | ||
+ | |||
+ | visualizer: | ||
+ | image: dockersamples/ | ||
+ | ports: | ||
+ | - "8080: | ||
+ | stop_grace_period: | ||
+ | volumes: | ||
+ | | ||
+ | deploy: | ||
+ | placement: | ||
+ | constraints: | ||
+ | |||
+ | networks: | ||
+ | frontend: | ||
+ | backend: | ||
+ | |||
+ | volumes: | ||
+ | db-data: | ||
</ | </ | ||
- | Connectez-vous sur chaque VM Docker pour constater que le service | + | Dans ce fichier on peut constater |
- | < | + | Dans un premier temps, regardez la clef **deploy** du service **worker** |
- | docker@manager1:/$ curl 192.168.99.100 | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | body { | + | |
- | width: 35em; | + | |
- | margin: 0 auto; | + | |
- | font-family: | + | |
- | } | + | |
- | </ | + | |
- | </ | + | |
- | < | + | |
- | < | + | |
- | <p>If you see this page, the nginx web server is successfully installed and | + | |
- | working. Further configuration is required.</ | + | |
- | <p>For online documentation and support please refer to | + | <file> |
- | <a href=" | + | ... |
- | Commercial support is available at | + | |
- | <a href="http://nginx.com/"> | + | mode: replicated |
+ | replicas: 1 | ||
+ | labels: [APP=VOTING] | ||
+ | restart_policy: | ||
+ | condition: on-failure | ||
+ | delay: 10s | ||
+ | max_attempts: | ||
+ | window: 120s | ||
+ | placement: | ||
+ | constraints: | ||
+ | ... | ||
+ | </file> | ||
- | < | + | La clef **deploy** permet de spécifier des options lors du déploiement du service |
- | </ | + | |
- | </ | + | |
- | docker@manager1:/$ curl 192.168.99.101 | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | body { | + | |
- | width: 35em; | + | |
- | margin: 0 auto; | + | |
- | font-family: | + | |
- | } | + | |
- | </ | + | |
- | </ | + | |
- | < | + | |
- | < | + | |
- | <p>If you see this page, the nginx web server is successfully installed and | + | |
- | working. Further configuration is required.</ | + | |
- | < | + | * **mode** - Il existe deux types de services. **Replicated** où on spécifie le nombre d' |
- | <a href=" | + | |
- | Commercial support is available at | + | |
- | <a href=" | + | |
- | < | + | {{ :elearning:workbooks:docker2: |
- | </ | + | |
- | </ | + | |
- | docker@manager1:/ | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | body { | + | |
- | width: 35em; | + | |
- | margin: 0 auto; | + | |
- | font-family: Tahoma, Verdana, Arial, sans-serif; | + | |
- | | + | |
- | </ | + | |
- | </ | + | |
- | < | + | |
- | < | + | |
- | <p>If you see this page, the nginx web server is successfully installed and | + | |
- | working. Further configuration is required.</ | + | |
- | < | + | * **replicas** - spécifie le nombre de replicas |
- | <a href=" | + | * **restart_policy** spécifie ce qui se passe en cas d' |
- | Commercial support is available at | + | * **placement** - spécifie où le service doit être démarré. |
- | <a href=" | + | |
- | < | + | Déployez maintenant le stack : |
- | </ | + | |
- | </ | + | |
- | docker@manager1:/$ curl 192.168.99.103 | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | body { | + | |
- | width: 35em; | + | |
- | margin: 0 auto; | + | |
- | font-family: | + | |
- | } | + | |
- | </ | + | |
- | </ | + | |
- | < | + | |
- | < | + | |
- | <p>If you see this page, the nginx web server is successfully installed and | + | |
- | working. Further configuration is required.</ | + | |
- | <p>For online documentation and support please refer to | + | <code> |
- | <a href=" | + | root@manager:~# docker stack deploy -c docker-stack.yml app |
- | Commercial support is available at | + | Creating network app_backend |
- | <a href=" | + | 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>< | + | <WRAP center round important 50%> |
- | </ | + | **Important** - Notez que chaque réseau et chaque service a comme préfixe le nom de l' |
- | </ | + | </WRAP> |
- | docker@manager1:/ | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | body { | + | |
- | width: 35em; | + | |
- | margin: 0 auto; | + | |
- | font-family: | + | |
- | } | + | |
- | </ | + | |
- | </ | + | |
- | < | + | |
- | < | + | |
- | <p>If you see this page, the nginx web server is successfully installed and | + | |
- | working. Further configuration is required.</p> | + | |
- | < | + | Consultez maintenant l' |
- | <a href=" | + | |
- | Commercial support is available at | + | |
- | <a href=" | + | |
- | <p>< | + | <code> |
- | </ | + | root@manager:~# docker stack ls |
- | </ | + | NAME SERVICES |
- | docker@manager1:/$ curl 192.168.99.105 | + | app |
- | < | + | </code> |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | body { | + | |
- | width: 35em; | + | |
- | margin: 0 auto; | + | |
- | font-family: | + | |
- | } | + | |
- | </ | + | |
- | </ | + | |
- | < | + | |
- | < | + | |
- | <p>If you see this page, the nginx web server is successfully installed and | + | |
- | working. Further configuration is required.</p> | + | |
- | < | + | Consultez ensuite l' |
- | <a href=" | + | |
- | Commercial support is available at | + | |
- | <a href=" | + | |
- | <p>< | + | <code> |
- | </body> | + | root@manager: |
- | </html> | + | ID NAME MODE REPLICAS |
+ | d0i4ac4fshw0 | ||
+ | funp5kboyip1 | ||
+ | dpdkc49oj671 | ||
+ | vrkahv38v5mn | ||
+ | t4u16cpdrx21 | ||
+ | so40eljbcviy | ||
</ | </ | ||
- | <WRAP center round important> | + | <WRAP center round important |
- | **Important** | + | **Important** |
</ | </ | ||
- | ====3.7 - Augmentation | + | Retournez à la fenêtre d' |
- | Actuellement, | + | {{ : |
+ | |||
+ | {{ : | ||
+ | |||
+ | Comme vous pouvez constater, conformément au fichier **docker-stack.yml**, | ||
+ | |||
+ | Retournez à votre connexion SSH et consultez l' | ||
< | < | ||
- | docker@manager1:/$ docker | + | root@manager:~# docker |
- | web scaled to 8 | + | NETWORK ID NAME |
+ | sw489bb290zb | ||
+ | smuxoglyudpo | ||
+ | lfizui95od90 | ||
+ | 24be8a0f0ef5 | ||
+ | d4c9b0c9437a | ||
+ | f3cb3bc3c581 | ||
+ | x7l4mk4ldb75 | ||
+ | de563e30d473 | ||
</ | </ | ||
- | Notez que la commande | + | <WRAP center round important 50%> |
+ | **Important** : Notez que les trois réseaux créés sont de type **overlay**. | ||
+ | </ | ||
< | < | ||
- | docker@manager1:/$ docker | + | root@worker1:~# docker |
- | ID NAME | + | NETWORK |
- | 4xtuwgbvr17l | + | qhysvpoolsw0 |
+ | f9a69d02de3b | ||
+ | ee22b3e623ca | ||
+ | f3cb3bc3c581 | ||
+ | x7l4mk4ldb75 | ||
+ | de563e30d473 | ||
</ | </ | ||
- | Des trois replicas supplémentaires, | + | <WRAP center round important 50%> |
+ | **Important** : Notez que seul le réseau **app_frontend** | ||
+ | </ | ||
< | < | ||
- | docker@manager1:/$ docker | + | root@worker2:~# docker |
- | ID NAME | + | NETWORK |
- | jkm2hapcthht | + | s4gbgi4isp1i |
- | q55eqdhr1qf1 | + | qhysvpoolsw0 |
- | imqdkw4ei6gs | + | 0e6c118bf3fd |
- | k4vjd0g7ijww | + | 0ce1d8369c29 |
- | b7xbmy1npgf9 | + | f3cb3bc3c581 |
- | kg3bivcg0wln | + | x7l4mk4ldb75 |
- | ik3u0jfgey64 | + | de563e30d473 |
- | 6bw5ptw7xao8 | + | |
</ | </ | ||
- | ====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**. | ||
+ | </ | ||
- | Pour se renseigner sur le statut du nœud courant, il convient d' | + | Consultez les informations concernant |
< | < | ||
- | docker@manager1:/$ docker | + | root@manager:~# docker inspect |
[ | [ | ||
{ | { | ||
- | "ID": "yuwpmvtfmdxn8i7nllkyzkxkp", | + | "Name": "app_backend", |
- | "Version": { | + | "Id": " |
- | "Index": | + | " |
+ | " | ||
+ | " | ||
+ | " | ||
+ | "IPAM": { | ||
+ | "Driver": | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
}, | }, | ||
- | "CreatedAt": | + | "Internal": |
- | "UpdatedAt": | + | "Attachable": |
- | "Spec": | + | "Ingress": |
- | "Labels": {}, | + | "ConfigFrom": { |
- | " | + | "Network": "" |
- | "Availability": "active" | + | |
}, | }, | ||
- | "Description": { | + | "ConfigOnly": |
- | "Hostname": "manager1", | + | " |
- | "Platform": | + | "7d0b28e4e1828b437af1a41f322acb5cf19afc25c42303986dd2c7b4d5aea568": |
- | "Architecture": "x86_64", | + | |
- | "OS": "linux" | + | "EndpointID": |
+ | " | ||
+ | "IPv4Address": "10.0.3.3/24", | ||
+ | "IPv6Address": "" | ||
}, | }, | ||
- | "Resources": { | + | "ef7227281d297b001bb0f60ac81a0c9926e8fb663a7f43eb201cced632dc5564": { |
- | "NanoCPUs": | + | "Name": |
- | "MemoryBytes": | + | "EndpointID": |
+ | " | ||
+ | " | ||
+ | " | ||
}, | }, | ||
- | "Engine": { | + | "lb-app_backend": { |
- | "EngineVersion": "17.06.2-ce", | + | "Name": "app_backend-endpoint", |
- | "Labels": | + | "EndpointID": "913845cbab9a6c3011eaaa87fcc66f10268b5e11554be9f1a20b1078f7b9b8a4", |
- | | + | "MacAddress": "02:42:0a:00:03:04", |
- | }, | + | "IPv4Address": "10.0.3.4/24", |
- | "Plugins": | + | "IPv6Address": "" |
- | { | + | |
- | "Type": | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | } | + | |
- | | + | |
- | }, | + | |
- | | + | |
- | | + | |
- | "CertIssuerSubject": "MBMxETAPBgNVBAMTCHN3YXJtLWNh", | + | |
- | " | + | |
} | } | ||
}, | }, | ||
- | "Status": { | + | "Options": { |
- | "State": "ready", | + | "com.docker.network.driver.overlay.vxlanid_list": "4101" |
- | "Addr": "192.168.99.100" | + | }, |
+ | "Labels": | ||
+ | | ||
}, | }, | ||
- | "ManagerStatus": | + | "Peers": |
- | "Leader": | + | |
- | "Reachability": "reachable", | + | |
- | "Addr": "192.168.99.100:2377" | + | "IP": "10.0.2.62" |
- | } | + | }, |
+ | | ||
+ | | ||
+ | " | ||
+ | } | ||
+ | ] | ||
} | } | ||
] | ] | ||
- | |||
</ | </ | ||
- | Pour se renseigner sur le statut d'un autre nœud, il convient d' | + | <WRAP center round important 50%> |
+ | **Important** : Notez que le réseau est **10.0.3.0/ | ||
+ | </ | ||
+ | |||
+ | Consultez les informations concernant | ||
< | < | ||
- | docker@manager1:/$ docker | + | root@manager:~# docker inspect |
[ | [ | ||
{ | { | ||
- | "ID": "1f5qtolgtonqmhjk5ppwc8x1b", | + | "Name": "app_frontend", |
- | "Version": { | + | "Id": " |
- | "Index": | + | " |
+ | " | ||
+ | " | ||
+ | " | ||
+ | "IPAM": { | ||
+ | "Driver": | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
}, | }, | ||
- | "CreatedAt": | + | "Internal": |
- | "UpdatedAt": | + | "Attachable": |
- | "Spec": | + | "Ingress": |
- | "Labels": {}, | + | "ConfigFrom": { |
- | " | + | "Network": "" |
- | "Availability": "active" | + | |
}, | }, | ||
- | "Description": { | + | "ConfigOnly": |
- | "Hostname": "worker1", | + | " |
- | "Platform": | + | "ef7227281d297b001bb0f60ac81a0c9926e8fb663a7f43eb201cced632dc5564": |
- | "Architecture": "x86_64", | + | |
- | "OS": "linux" | + | "EndpointID": |
+ | " | ||
+ | "IPv4Address": "10.0.2.10/ | ||
+ | "IPv6Address": "" | ||
}, | }, | ||
- | "Resources": { | + | "lb-app_frontend": { |
- | "NanoCPUs": | + | "Name": |
- | "MemoryBytes": | + | "EndpointID": |
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
}, | }, | ||
- | | + | { |
- | "EngineVersion": "17.06.2-ce", | + | "Name": "5cc4b863da9f", |
- | "Labels": | + | "IP": "10.0.2.64" |
- | | + | |
- | }, | + | |
- | " | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | } | + | |
- | ] | + | |
}, | }, | ||
- | | + | { |
- | "TrustRoot": | + | "Name": "377986fb7d5a", |
- | " | + | "IP": "10.0.2.62" |
- | "CertIssuerPublicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAESqAtRvKPI24/ | + | |
} | } | ||
- | | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | } | + | |
} | } | ||
] | ] | ||
</ | </ | ||
- | L' | + | <WRAP center round important 50%> |
+ | **Important** : Notez que le réseau est **10.0.2.0/ | ||
+ | </ | ||
- | < | + | Consultez les informations concernant le réseau |
- | docker@manager1:/ | + | |
- | ID: | + | |
- | Hostname: | + | |
- | Joined at: | + | |
- | Status: | + | |
- | | + | |
- | | + | |
- | | + | |
- | Platform: | + | |
- | | + | |
- | | + | |
- | Resources: | + | |
- | | + | |
- | | + | |
- | Plugins: | + | |
- | | + | |
- | | + | |
- | | + | |
- | Engine Version: | + | |
- | Engine Labels: | + | |
- | - provider=virtualbox | + | |
- | TLS Info: | + | |
- | | + | |
- | -----BEGIN CERTIFICATE----- | + | |
- | MIIBajCCARCgAwIBAgIUNuU4I89kxId2QXulofRKxJa9XRcwCgYIKoZIzj0EAwIw | + | |
- | EzERMA8GA1UEAxMIc3dhcm0tY2EwHhcNMTcwOTA4MTEzOTAwWhcNMzcwOTAzMTEz | + | |
- | OTAwWjATMREwDwYDVQQDEwhzd2FybS1jYTBZMBMGByqGSM49AgEGCCqGSM49AwEH | + | |
- | A0IABEqgLUbyjyNuP35aAzW+aqVB8AkghvpF5hq1KnMveHbl4Ilr+EyDjlYZkbnt | + | |
- | Gb/ | + | |
- | Af8EBTADAQH/ | + | |
- | PQQDAgNIADBFAiB34DOvDtIYjJ+GzbPMGu9Dd/ | + | |
- | TJBucTomFSDsj5Y/ | + | |
- | -----END CERTIFICATE----- | + | |
- | + | ||
- | | + | |
- | | + | |
- | </ | + | |
- | + | ||
- | ====3.9 - Haute Disponibilité==== | + | |
- | + | ||
- | Quand un nœud est actif, il est capable de recevoir de nouvelles tâches à partir du manager : | + | |
- | + | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | + | ||
- | Rappelez-vous que la swarm contient 6 VM Docker | + | |
< | < | ||
- | docker@manager1:/$ docker | + | root@manager:~# docker |
- | ID HOSTNAME | + | [ |
- | 1f5qtolgtonqmhjk5ppwc8x1b | + | { |
- | kmyjdwp9ojhzje4hlw7ffhuxv | + | " |
- | oyszb44k8yw5btz3c1wq2ot2e | + | " |
- | p6jpyopzzy0zg4znegi63hzjq | + | " |
- | yitkfnk99ecisrny9g3r9kfhk | + | " |
- | yuwpmvtfmdxn8i7nllkyzkxkp * | + | " |
+ | " | ||
+ | " | ||
+ | | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | ] | ||
</ | </ | ||
- | 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/ | ||
+ | </ | ||
- | < | + | Schématiquement, |
- | docker@manager1:/$ docker service ps web | + | |
- | ID NAME IMAGE | + | |
- | jkm2hapcthht | + | |
- | q55eqdhr1qf1 | + | |
- | imqdkw4ei6gs | + | |
- | k4vjd0g7ijww | + | |
- | b7xbmy1npgf9 | + | |
- | kg3bivcg0wln | + | |
- | ik3u0jfgey64 | + | |
- | 6bw5ptw7xao8 | + | |
- | </ | + | |
- | dont deux se trouvent sur worker1 | + | {{ :elearning: |
- | < | + | Dernièrement, |
- | docker@manager1:/ | + | |
- | ID NAME IMAGE | + | |
- | k4vjd0g7ijww | + | |
- | 6bw5ptw7xao8 | + | |
- | </ | + | |
- | + | ||
- | Mettez worker1 en mode d' | + | |
< | < | ||
- | docker@manager1:/$ docker | + | root@manager:~# docker |
- | worker1 | + | NAME SERVICES |
- | </ | + | app |
- | 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 | ||
- | < | + | root@manager:~# docker ps -a |
- | docker@manager1:/$ docker | + | CONTAINER |
- | ID | + | d02c6115724c |
- | jkm2hapcthht | + | |
- | q55eqdhr1qf1 | + | |
- | imqdkw4ei6gs | + | |
- | 6cv6j4tz0nk5 | + | |
- | k4vjd0g7ijww | + | |
- | b7xbmy1npgf9 | + | |
- | kg3bivcg0wln | + | |
- | ik3u0jfgey64 | + | |
- | wht3r8c9wga6 | + | |
- | 6bw5ptw7xao8 | + | |
</ | </ | ||
- | ====3.10 | + | ----- |
- | Pour supprimer un service il convient d' | + | Copyright © 2024 Hugh Norris. |
- | + | ||
- | < | + | |
- | docker@manager1:/ | + | |
- | web | + | |
- | </ | + | |
- | + | ||
- | < | + | |
- | docker@manager1:/ | + | |
- | ID NAME MODE REPLICAS | + | |
- | </ | + | |
- | + | ||
- | < | + | |
- | docker@manager1:/ | + | |
- | [] | + | |
- | Status: Error: no such service: web, Code: 1 | + | |
- | </ | + | |
- | + | ||
- | Sortez de manager1 et démarrez le serveur VNC dans la machine virtuelle **debian9** en tant que **trainee** : | + | |
- | + | ||
- | < | + | |
- | docker@manager1:/ | + | |
- | root@debian9: | + | |
- | trainee@debian9: | + | |
- | + | ||
- | New ' | + | |
- | + | ||
- | Starting applications specified in / | + | |
- | Log file is / | + | |
- | </ | + | |
- | + | ||
- | ====3.11 - Sauvegarder Docker Swarm==== | + | |
- | + | ||
- | La configuration de Docker Swarm est contenue dans le répertoire **/ | + | |
- | + | ||
- | * arrêt du service Docker sur le Manager à sauvegarder, | + | |
- | * sauvegarde du répertoire **/ | + | |
- | * redémarrage du service Docker sur le Manager concerné. | + | |
- | + | ||
- | ====3.12 - Restaurer Docker Swarm==== | + | |
- | + | ||
- | Le procédure de resturation est : | + | |
- | + | ||
- | * arrêt du service Docker sur un nouveau Manager, | + | |
- | * suppression du contenu du répertoire **/ | + | |
- | * restauration du répertoire **/ | + | |
- | * exécution de la commande **docker swarm init --force-new-cluster** sur le nouveau Manager, | + | |
- | * ajout des Managers et Workers à Swarm. | + | |
- | + | ||
- | ----- | + | |
- | < | + | |
- | <div align=" | + | |
- | Copyright © 2021 Hugh NORRIS | + | |
- | </ | + | |
- | </ | + |