Différences

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

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
elearning:workbooks:docker1:drf05 [2020/02/15 13:23] adminelearning:workbooks:docker1:drf05 [2021/12/29 10:32] (Version actuelle) admin
Ligne 1: Ligne 1:
 +
 ~~PDF:LANDSCAPE~~ ~~PDF:LANDSCAPE~~
  
-Version : **2020.01**+Version : **2022.01**
  
 Dernière mise-à-jour : ~~LASTMOD~~ Dernière mise-à-jour : ~~LASTMOD~~
  
-======DOF202 - Docker Compose, Docker Machine et Docker Swarm======+======XW330 - Docker : Mise en oeuvre======
  
-Cette unité contient trois LABs :+=====Contenu du Module=====
  
-  * LAB #2 - Utiliser docker-compose, +  * **XW330 Docker : Mise en oeuvre**. 
-  LAB #3 - Création de Machines Virtuelles Docker, +    Contenu du Module 
-  LAB #4 - Utiliser Docker Swarm.+    * Prérequis 
 +      * Matériel 
 +      * Logiciels 
 +      * Internet 
 +    * Utilisation de l'Infrastructure 
 +    Programme de la Formation
  
-=====Docker Compose=====+=====Prérequis=====
  
-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**.+==== Matériel====
  
-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 constituantespour lier des conteneurs et pour définir l'environnement.+  * Un poste (MacOS, LinuxWindows(tm) ou Solaris(tm)), 
 +  Clavier AZERTY FR ou QWERTY US, 
 +  4 Go de RAM minimum, 
 +  Processeur 2 cœurs minimum, 
 +  Un casque ou des écouteurs, 
 +  * Un micro (optionnel).
  
-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**.+====Logiciels====
  
-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**.+  Si Windows(tm) Putty et WinSCP, 
 +  Navigateur Web ChromeEdge ou Firefox.
  
-====Installation====+====Internet====
  
-Récupérez docker-compose avec **curl** :+  Un accès à Internet **rapide** (4G minimum) **sans** passer par un proxy, 
 +  * Accès **débloqué** aux domaines suivants : https://ittraining.network, https://ittraining.io ainsi que leurs sous-domaines et https://online.ittraining.team/
 +  Ports accessibles 80,443.
  
-<code> +=====Utilisation de l'Infrastructure=====
-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 +
-  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current +
-                                 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  +Au départ de votre formation, votre formateur vous attribue un ID allant de Trainee01 à Trainee10.
-</code>+
  
-Rendez **/usr/local/bin/docker-compose** exécutable :+Pour avoir accès à vos machines virtuelles, vous devez d'abord vous connecter à votre gateway vers notre cloud. Ouvrez votre navigateur web **Chrome**, **Edge** ou **Firefox** et saisissez l'URL selon le tableau ci-dessous :
  
-<code> +^ ID ^ URL ( Notez http: et non https: ) ^  
-root@debian9:~# ls -l /usr/local/bin/docker-compose  +| Trainee01 | http://compute01.ittraining.network | 
--rw-r--r-- 1 root staff 5263681 Jan  2 16:29 /usr/local/bin/docker-compose +| Trainee02 | http://compute02.ittraining.network | 
-root@debian9:~# chmod u+x /usr/local/bin/docker-compose  +| Trainee03 | http://compute03.ittraining.network | 
-</code>+| Trainee04 | http://compute04.ittraining.network | 
 +| Trainee05 | http://compute05.ittraining.network | 
 +| Trainee06 | http://compute06.ittraining.network | 
 +| Trainee07 | http://compute07.ittraining.network | 
 +| Trainee08 | http://compute08.ittraining.network |  
 +| Trainee09 | http://compute09.ittraining.network | 
 +| Trainee10 | http://compute10.ittraining.network |
  
-Avant de commencerinstallez l'utilitaire **tree** :+Dans la boîte de connexionentrez votre ID et le mot de passe qui vous a été **fourni par votre formateur**.
  
-<code> +Cliquez ensuite sur la connexion **Gateway-XX_SSH** ou XX est le numéro dans votre **ID**.
-root@debian9:~# apt-get install tree +
-Reading package lists... Done +
-Building dependency tree        +
-Reading state information... Done +
-The following NEW packages will be installed: +
-  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://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>+
  
-====LAB #2 - Utiliser docker-compose====+Si vous souhaitez avoir accès à votre Gateway directement en utilisant une connexion SSH, utilisez la commande appropriée issue du tableau suivant : 
  
-Dans ce LAB vous allez créer une application simple ayant deux environnements différents :+^ ID ^ Commande ^ 
 +| Trainee01 | ssh -l trainee compute01.ittraining.network -p 21022 | 
 +| Trainee02 | ssh -l trainee compute02.ittraining.network -p 21122 | 
 +| Trainee03 | ssh -l trainee compute03.ittraining.network -p 21222 | 
 +| Trainee04 | ssh -l trainee compute04.ittraining.network -p 21322 | 
 +| Trainee05 | ssh -l trainee compute05.ittraining.network -p 21422 | 
 +| Trainee06 | ssh -l trainee compute06.ittraining.network -p 21522 | 
 +| Trainee07 | ssh -l trainee compute07.ittraining.network -p 21622 | 
 +| Trainee08 | ssh -l trainee compute08.ittraining.network -p 21722 | 
 +| Trainee09 | ssh -l trainee compute09.ittraining.network -p 21822 | 
 +| Trainee10 | ssh -l trainee compute10.ittraining.network -p 21922 | 
  
-  * development +Utilisez le mot de passe qui vous a été fourni par votre formateur.
-  * production+
  
-afin d'utiliser deux configurations différentes selon l'environnement désiré.+L'adresse IP de la machine virtuelle est :
  
-Commencez par créer l'arborescence du projet :+^ Machine ^ Nom d'hôte ^ Adresse IP ^ 
 +| Debian_9 | debian9.i2tch.loc | 10.0.2.60 |
  
-<code> +Les noms d'utilisateurs et les mots de passe sont :
-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>+
  
-Utilisez l'utilitaire tree pour visualiser la structure du projet :+^ Utilisateur ^ Mot de Passe ^ 
 +| trainee | trainee | 
 +| root | fenestros |
  
-<code> +Dernièrement connectez-vous à la machine virtuelle utilisée pour cette formation :
-root@debian9:~# cd MyApp +
-root@debian9:~/MyApp# tree +
-+
-├── common +
-│   └── docker-compose.yml +
-├── development +
-│   ├── content +
-│   │   ├── Dockerfile +
-│   │   └── index.html +
-│   └── docker-compose.yml +
-└── production +
-    ├── content +
-    │   ├── Dockerfile +
-    │   └── index.html +
-    └── docker-compose.yml+
  
-5 directories, 7 files +  $ ssh -l trainee 10.0.2.60
-</code>+
  
-Ce projet comporte la structure suivante :+=====Programme de la Formation=====
  
-  * **common** +====Jour #1====
-    * La configuration commune aux deux environnements sera placée dans le fichier **MyApp/common/docker-compose.yml**. +
-  * **development** +
-    * La configuration spécifique à l'environnement **development** sera placée dans le fichier **MyApp/development/common/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/common/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 :+  * **XW330 - Docker : Mise en oeuvre** - 1 heure. 
 +    Contenu du Module 
 +    Prérequis 
 +      Matériel 
 +      * Logiciels 
 +      * Internet 
 +    * Utilisation de l'Infrastructure 
 +    * Programme de la Formation
  
-<code> +  * **DOF101 - La Virtualisation par Isolation** - 3 heures. 
-root@debian9:~/MyAppvi development/content/Dockerfile +    * Présentation de la Virtualisation par Isolation 
 +      * Historique 
 +    * Présentation des Namespaces 
 +    * Présentation des CGroups 
 +      * LAB #1 - Travailler avec les CGroups 
 +        * 1.1 - Limitation de la Mémoire 
 +        * 1.2 - Le Paquet cgroup-tools 
 +          * La commande cgcreate 
 +          * La Commande cgexec 
 +          * La Commande cgdelete 
 +          * Le Fichier /etc/cgconfig.conf 
 +    * Présentation de Linux Containers 
 +      * LAB #2 - Travailler avec LXC 
 +        * 2.1 - Installation 
 +        * 2.2 - Création d'un Conteneur Simple 
 +        * 2.3 - Démarrage d'un Conteneur Simple 
 +        * 2.4 - S'attacher à un Conteneur Simple 
 +        * 2.5 - Commandes LXC de Base 
 +          * La Commande lxc-console 
 +          * La Commande lxc-stop 
 +          * La Commande lxc-execute 
 +          * La Commande lxc-info 
 +          * La Commande lxc-freeze 
 +          * La Commande lxc-unfreeze 
 +          * Autres commandes 
 +        * 2.6 - Création d'un Conteneur Non-Privilégié 
 +          * User Namespaces 
 +          * Création d'un Utilisateur Dédié 
 +          * Création du Mappage 
 +          * Création du Conteneur 
 +          * Contrôle du Mappage 
 +        * 2.7 - Création d'un Conteneur Éphémère 
 +          * La Commande lxc-copy 
 +        * 2.8 - Sauvegarde des Conteneurs 
 +          * La Commande lxc-snapshot
  
-root@debian9:~/MyAppcat development/content/Dockerfile  +  * **DOF102 - Démarrer avec Docker** - 3 heures. 
-FROM tianon/true+    * Présentation de Docker 
 +    * LAB #1 - Travailler avec Docker 
 +      * 1.1 - Installer docker 
 +      * 1.2 - Démarrer un Conteneur 
 +      * 1.3 - Consulter la Liste des Conteneurs et Images 
 +      * 1.4 - Rechercher une Image dans un Dépôt 
 +      * 1.5 - Supprimer un Conteneur d'une Image 
 +      * 1.6 - Créer une Image à partir d'un Conteneur Modifié 
 +      * 1.7 - Supprimer une Image 
 +      * 1.8 - Créer un Conteneur avec un Nom Spécifique 
 +      * 1.9 - Exécuter une Commande dans un Conteneur 
 +      * 1.10 - Injecter des Variables d'Environnement dans un Conteneur 
 +      * 1.11 - Modifier le Nom d'Hôte d'un Conteneur 
 +      * 1.12 - Mapper des Ports d'un Conteneur 
 +      * 1.13 - Démarrer un Conteneur en mode Détaché 
 +      * 1.14 - Accéder aux Services d'un Conteneur de l'Extérieur 
 +      * 1.15 - Arrêter et Démarrer un Conteneur 
 +      * 1.16 - Utiliser des Signaux avec un Conteneur 
 +      * 1.17 - Forcer la Suppression d'un Conteneur en cours d'Exécution 
 +      * 1.18 - Utilisation Simple d'un Volume 
 +      * 1.19 - Télécharger une image sans créer un conteneur 
 +      * 1.20 - S'attacher à un conteneur en cours d'exécution 
 +      * 1.21 - Installer un logiciel dans le conteneur 
 +      * 1.22 - Utilisation de la commande docker commit 
 +      * 1.23 - Se connecter au serveur du conteneur de l'extérieur
  
-VOLUME ["/usr/share/nginx/html/"]  +====Jour #2====
-ADD index.html /usr/share/nginx/html/+
  
-root@debian9:~/MyAppcp development/content/Dockerfile production/content/Dockerfile  +  * **DOF103 - Gérer les Images Docker** - 2 heures. 
-</code>+    * Contenu du Module 
 +    * LAB #1 - Re-créer une image officielle docker 
 +      * 1.1 - Utilisation d'un Dockerfile 
 +      * 1.2 - FROM 
 +      * 1.3 - RUN 
 +      * 1.4 - ENV 
 +      * 1.5 - VOLUME 
 +      * 1.6 - COPY 
 +      * 1.7 - ENTRYPOINT 
 +      * 1.8 - EXPOSE 
 +      * 1.9 - CMD 
 +      * 1.10 - Autres Commandes 
 +    * LAB #2 - Créer un Dockerfile 
 +      * 2.1 - Création et test du script 
 +      * 2.2 - Bonnes Pratiques liées au Cache
  
-Créez maintenant le fichier **MyApp/common/docker-compose.yml** :+  * **DOF104 Gestion des Volumes, du Réseau et des Ressources** - 2 heures. 
 +    LAB #1 - Gestion des Volumes 
 +      1.1 - Gestion Automatique par Docker 
 +      * 1.2 - Gestion Manuelle d'un Volume 
 +    * LAB #2 - Gestion du Réseau 
 +      * 2.1 - L'Approche Réseau Docker 
 +        * Bridge 
 +        * Host 
 +        * None 
 +        * Liens 
 +      * 2.2 - Lancer Wordpress dans un container 
 +      * 2.3 - Gestion d'une Architecture de Microservices 
 +    * LAB #3 - Superviser les Conteneurs 
 +      * 3.1 - Les Journaux 
 +      * 3.2 - Les Processus 
 +      * 3.3 - L'Activité en Continu 
 +    * LAB #4 - Gestion des Ressources 
 +      * 4.1 - Limiter la Mémoire
  
-<code> +  * **DOF202 - Docker Compose, Docker Machine et Docker Swarm** - 2 heures. 
-root@debian9:~/MyAppvi common/docker-compose.yml+    * LAB #1 - Docker Compose 
 +      * 1.1 - Installation 
 +      * 1.2 - Utiliser docker-compose 
 +    * LAB #2 - Docker Machine 
 +      * 2.1 - Présentation 
 +      * 2.2 - Création de Machines Virtuelles Docker 
 +      * 2.3 - Lister les VM Docker 
 +      * 2.4 - Obtenir l'adresse IP des VM 
 +      * 2.5 - Se connecter à une VM Docker 
 +    * LAB #3 - Docker Swarm 
 +      * 3.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.9 - Haute Disponibilité 
 +      * 3.10 - Supprimer un Service 
 +      * 3.11 - Sauvegarder Docker Swarm 
 +      * 3.12 - Restaurer Docker Swarm
  
-root@debian9:~/MyApp# cat common/docker-compose.yml +  * **XW330 Validation de la Formation** - 1 heure
-web:  +    * Support de Cours 
-  image: nginx  +    * Rappel du Programme de la Formation 
-  ports:  +      * Jour #1 
-    - 8082:80 +      * Jour #2 
-</code>+    * Évaluation de la Formation 
 +    * Validation des acquis
  
-Les deux fichiers **MyApp/development/docker-compose.yml** et **MyApp/production/docker-compose.yml** sont identiques :+-----
  
-<code> +Copyright © 2022 Hugh Norris Document non-contractuel. Le programme peut être modifié sans préavis.
-root@debian9:~/MyApp# vi development/docker-compose.yml +
-  +
-root@debian9:~/MyApp# cat development/docker-compose.yml  +
-web:  +
-  extends:  +
-    file: ../common/docker-compose.yml  +
-    service: web  +
-  volumes_from:  +
-    - content +
- +
-content:  +
-  build: content +
- +
-root@debian9:~/MyApp# cp 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:~/MyApp# cat development/content/index.html +
-<html> +
-<body> +
-<center>This is the development environement</center> +
-</body> +
-</html> +
- +
-root@debian9:~/MyApp# vi production/content/index.html +
- +
-root@debian9:~/MyApp# cat production/content/index.html +
-<html> +
-<body> +
-<center>This is the production environement</center> +
-</body> +
-</html> +
-</code> +
- +
-Placez-vous dans le sous-répertoire **development** et exécutez la commande **docker-compose up -d** : +
- +
-<code> +
-root@debian9:~/MyApp/development# docker-compose up -d +
-Creating development_content_1... +
-Building content... +
-Step 1/3 : FROM tianon/true +
- ---> 1298b2036003 +
-Step 2/3 : VOLUME /usr/share/nginx/html/ +
- ---> Running in 8619de833add +
- ---> 694e4f111996 +
-Removing intermediate container 8619de833add +
-Step 3/3 : ADD index.html /usr/share/nginx/html/ +
- ---> f6fabac6703b +
-Removing intermediate container a9bec35dba66 +
-Successfully built f6fabac6703b +
-Successfully tagged development_content:latest +
-Creating development_web_1... +
-</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**. +
- +
-Les options de la commande **docker-compose** sont : +
- +
-<code> +
-root@debian9:~# docker-compose --help +
-Fast, isolated development environments using Docker. +
- +
-Usage: +
-  docker-compose [options] [COMMAND] [ARGS...] +
-  docker-compose -h|--help +
- +
-Options: +
-  --verbose                 Show more output +
-  --version                 Print version and exit +
-  -f, --file FILE           Specify an alternate compose file (default: docker-compose.yml) +
-  -p, --project-name NAME   Specify an alternate project name (default: directory name) +
- +
-Commands: +
-  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 : +
- +
-<code> +
-root@debian9:~/MyApp/development# docker images +
-REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE +
-development_content        latest              f6fabac6703b        19 seconds ago      209B +
-... +
-</code> +
- +
-Constatez la présence des deux conteneurs **nginx:latest** et **development_content** : +
- +
-<code> +
-root@debian9:~/MyApp/development# docker ps -a +
-CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS                           PORTS                  NAMES +
-6955516dceff        nginx:latest          "nginx -g 'daemon ..."   28 seconds ago      Up 27 seconds                    0.0.0.0:8082->80/tcp   development_web_1 +
-9a1876d7a145        development_content   "/true"                  28 seconds ago      Exited (0) 27 seconds ago                               development_content_1 +
-... +
-</code> +
- +
-Utilisez maintenant lynx pour consultez **http://localhost:8082** : +
- +
-<code> +
-root@debian9:~/MyApp/development# lynx --dump http://localhost:8082 +
-                    This is the development environement +
- +
- +
-root@debian9:~/MyApp/development#  +
-</code> +
- +
-Arrêtez docker-compose : +
- +
-<code> +
-root@debian9:~/MyApp/development# docker-compose stop  +
-Stopping development_web_1... +
-root@debian9:~/MyApp/development# docker ps -a +
-CONTAINER ID        IMAGE                 COMMAND                  CREATED              STATUS                           PORTS               NAMES +
-6955516dceff        nginx:latest          "nginx -g 'daemon ..."   About a minute ago   Exited (0) 5 seconds ago                             development_web_1 +
-9a1876d7a145        development_content   "/true"                  About a minute ago   Exited (0) About a minute ago                        development_content_1 +
-... +
-</code> +
- +
-Placez-vous maintenant dans le sous-répertoire **production** et exécutez de nouveau la commande **docker-compose up -d** : +
- +
-<code> +
-root@debian9:~/MyApp/development# cd ../production/ +
-root@debian9:~/MyApp/production# docker-compose up -d +
-Creating production_content_1... +
-Building content... +
-Step 1/3 : 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** : +
- +
-<code> +
-root@debian9:~/MyApp/production# docker ps -a +
-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"                  4 seconds ago       Exited (0) 3 seconds ago                               production_content_1 +
-6955516dceff        nginx:latest          "nginx -g 'daemon ..."   2 minutes ago       Exited (0) About a minute ago                          development_web_1 +
-9a1876d7a145        development_content   "/true"                  2 minutes ago       Exited (0) 2 minutes ago                               development_content_1 +
-... +
-</code> +
- +
-En étant dans le contexte **production**, il est possible d'utiliser la commande **docker-compose ps** : +
- +
-<code> +
-root@debian9:~/MyApp/production# docker-compose ps +
-        Name                 Command          State           Ports          +
---------------------------------------------------------------------------- +
-production_content_1   /true                  Exit 0                         +
-production_web_1       nginx -g daemon off;   Up       0.0.0.0:8082->80/tcp  +
-</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> +
-root@debian9:~/MyApp/production# cd ../development/ +
-root@debian9:~/MyApp/development# docker-compose ps +
-        Name                  Command          State    Ports  +
-------------------------------------------------------------- +
-development_content_1   /true                  Exit 0          +
-development_web_1       nginx -g daemon off;   Exit 0    +
-</code> +
- +
-Utilisez maintenant lynx pour consultez **http://localhost:8082** : +
- +
-<code> +
-root@debian9:~/MyApp/development# lynx --dump http://localhost:8082 +
-                     This is the production environement +
- +
- +
-root@debian9:~/MyApp/development# +
-</code> +
- +
-=====Docker Machine===== +
- +
-====Présentation==== +
- +
-Docker Machine est un outil qui vous permet d'installer docker sur des hôtes virtuels et de gérer les hôtes en utilisant des commandes spécifiques à docker-machine. Il est donc possible d'utiliser cet outil pour créer des hôtes docker localement, sur le réseau, dans un data center ou dans le cloud (Azure, AWS, Digital Ocean par exemple). +
- +
-Le jeu de commandes de docker-machine permet de démarrer, surveiller, arrêter et re-démarrer un hôte géré, de mettre à jour le client/daemon docker et de configurer un client docker afin qu'il "parle" à votre machine hôte. +
- +
-====Préparation==== +
- +
-===Docker-CE=== +
- +
-Installer Docker-CE sur votre machine hôte : +
- +
-==Mac== +
- +
-  * Voir le lien **[[https://docs.docker.com/docker-for-mac/install/]]**. +
- +
-==Linux== +
- +
-  * Ubuntu - voir le lien **[[https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/]]**, +
-  * Debian - voir le lien **[[https://docs.docker.com/engine/installation/linux/docker-ce/debian/]]**, +
-  * CentOS - voir le lien **[[https://docs.docker.com/engine/installation/linux/docker-ce/centos/]]**, +
-  * Fedora - voir le lien **[[https://docs.docker.com/engine/installation/linux/docker-ce/fedora/]]**, +
- +
-==Windows 7, 8 et 10== +
- +
-  * Téléchargez Docker Toolbox à partir de cette page **[[https://docs.docker.com/toolbox/toolbox_install_windows/]]** +
-  * Fermez toutes les machines virtuelles ainsi que VirtualBox, +
-  * Installez **DockerToolBox.exe** (décochez VirtualBox dans la liste de produits à installer), +
-  * Exécutez Docker Toolbox et laissez l'application créer une machine virtuelle, +
-  * Ouvrez VirtualBox. Vous verrez une machine virtuelle Default, +
-  * Ouvrez **cmd** et allez directement au LAB #3. +
- +
-====Installation==== +
- +
-Pour installer docker-machine sur votre **machine hôte**, utilisez une des commandes suivantes : +
- +
-===Mac=== +
- +
-<code> +
-curl -L https://github.com/docker/machine/releases/download/v0.12.2/docker-machine-`uname -s`-`uname -m` >/usr/local/bin/docker-machine && chmod +x /usr/local/bin/docker-machine +
-</code> +
- +
-===Linux=== +
- +
-<code> +
-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 +
-</code> +
- +
-===Windows=== +
- +
-Si vous utilisez **[[https://git-for-windows.github.io/|Git BASH]]** : +
- +
-<code> +
-if [[ ! -d "$HOME/bin" ]]; then mkdir -p "$HOME/bin"; fi && curl -L https://github.com/docker/machine/releases/download/v0.12.2/docker-machine-Windows-x86_64.exe > "$HOME/bin/docker-machine.exe" && chmod +x "$HOME/bin/docker-machine.exe" +
-</code> +
- +
-Si vous n'utilisez PAS **Git BASH** : +
- +
-Téléchargez la version adéquate pour l'architecture de votre machine à partir de l'adresse **[[https://github.com/docker/machine/releases/]]**. +
- +
-====LAB #3 - Création de Machines Virtuelles Docker===== +
- +
-La création d'une machine se fait simplement en utilisant la commande **docker-machine** avec la sous-commande **create**. Cette sous-commande prend l'option **--driver** ou **-d** qui indique le fournisseur à utiliser : +
- +
-^ Fournisseur ^ driver ^ +
-| [[https://aws.amazon.com/fr/|Amazon Web Services]] | [[https://docs.docker.com/machine/drivers/aws/|amazonec2]] | +
-| [[https://www.digitalocean.com/|Digital Ocean]] | [[https://docs.docker.com/machine/drivers/digital-ocean/|digitalocean]] | +
-| [[https://www.exoscale.ch/|Exoscale]] | [[https://docs.docker.com/machine/drivers/exoscale/|exoscale]] | +
-| [[https://cloud.google.com/compute/?hl=fr|Google Compute Engine]] | [[https://cloud.google.com/compute/?hl=fr|google]] | +
-| [[http://www.softlayer.com/fr|IBM Softlayer]] | [[https://docs.docker.com/machine/drivers/soft-layer/|softlayer]] | +
-| [[https://msdn.microsoft.com/fr-fr/library/hh831531(v=ws.11).aspx|Microsoft Hyper-V]] | [[https://docs.docker.com/machine/drivers/digital-ocean/|hyperv]] | +
-| [[https://azure.microsoft.com/fr-fr/|Microsoft Azure]] | [[https://docs.docker.com/machine/drivers/azure/|azure]] | +
-| [[https://www.openstack.org/|OpenStack]] | [[https://docs.docker.com/machine/drivers/openstack/|openstack]] | +
-| [[https://www.virtualbox.org/|Oracle VirtualBox]] | [[https://docs.docker.com/machine/drivers/digital-ocean/|virtualbox]] | +
-| [[https://www.rackspace.com/en-gb|Rackspace]] | [[https://docs.docker.com/machine/drivers/rackspace/|rackspace]] | +
-| [[https://www.vmware.com/fr/products/fusion.html|VMware Fusion]] | [[https://docs.docker.com/machine/drivers/vm-fusion/|vmwarefusion]] | +
-| [[https://www.vmware.com/cloud-services/infrastructure.html|VMware vCloud Air]] | [[https://docs.docker.com/machine/drivers/vm-cloud/|vmwarevcloudair]] | +
-| [[https://www.vmware.com/fr/products/vsphere.html|VMware vSphere]] | [[https://docs.docker.com/machine/drivers/vsphere/|vmwarevsphere]] | +
- +
-Créez donc la machine virtuelle **manager1** : +
- +
-<code> +
-hnorris-laptop ~ # docker-machine create --driver virtualbox manager1 +
-Creating CA: /root/.docker/machine/certs/ca.pem +
-Creating client certificate: /root/.docker/machine/certs/cert.pem +
-Running pre-create checks... +
-(manager1) Image cache directory does not exist, creating it at /root/.docker/machine/cache... +
-(manager1) No default Boot2Docker ISO found locally, downloading the latest release... +
-(manager1) Latest release for github.com/boot2docker/boot2docker is v17.06.2-ce +
-(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> +
- +
-Les options de la commande **docker-machine** sont : +
- +
-<code> +
-hnorris-laptop ~ # docker-machine --help +
-Usage: docker-machine [OPTIONS] COMMAND [arg...] +
- +
-Create and manage machines running Docker. +
- +
-Version: 0.12.2, build 9371605 +
- +
-Author: +
-  Docker Machine Contributors - <https://github.com/docker/machine> +
- +
-Options: +
-  --debug, -D Enable debug mode +
-  --storage-path, -s "/root/.docker/machine" Configures storage path [$MACHINE_STORAGE_PATH] +
-  --tls-ca-cert CA to verify remotes against [$MACHINE_TLS_CA_CERT] +
-  --tls-ca-key Private key to generate certificates [$MACHINE_TLS_CA_KEY] +
-  --tls-client-cert Client cert to use for TLS [$MACHINE_TLS_CLIENT_CERT] +
-  --tls-client-key Private key used in client TLS auth [$MACHINE_TLS_CLIENT_KEY] +
-  --github-api-token Token to use for requests to the Github API [$MACHINE_GITHUB_API_TOKEN] +
-  --native-ssh Use the native (Go-based) SSH implementation. [$MACHINE_NATIVE_SSH] +
-  --bugsnag-api-token BugSnag API token for crash reporting [$MACHINE_BUGSNAG_API_TOKEN] +
-  --help, -h show help +
-  --version, -v print the version +
-   +
-Commands: +
-  active Print which machine is active +
-  config Print the connection config for machine +
-  create Create a machine +
-  env Display the commands to set up the environment for the Docker client +
-  inspect Inspect information about a machine +
-  ip Get the IP address of a machine +
-  kill Kill a machine +
-  ls List machines +
-  provision Re-provision existing machines +
-  regenerate-certs Regenerate TLS Certificates for a machine +
-  restart Restart a machine +
-  rm Remove a machine +
-  ssh Log into or run a command on a machine with SSH. +
-  scp Copy files between machines +
-  start Start a machine +
-  status Get the status of a machine +
-  stop Stop a machine +
-  upgrade Upgrade a machine to the latest version of Docker +
-  url Get the URL of a machine +
-  version Show the Docker Machine version or a machine docker version +
-  help Shows a list of commands or help for one command +
-   +
-Run 'docker-machine COMMAND --help' for more information on a command. +
-</code>  +
- +
-Créez maintenant 5 travailleurs - **worker1** jusqu'à **worker5** : +
- +
-<code> +
-hnorris-laptop ~ # docker-machine create --driver virtualbox worker1 +
-Running pre-create checks... +
-Creating machine... +
-(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> +
-hnorris-laptop ~ # docker-machine create --driver virtualbox worker2 +
-... +
-hnorris-laptop ~ # docker-machine create --driver virtualbox worker3 +
-... +
-hnorris-laptop ~ # docker-machine create --driver virtualbox worker4 +
-... +
-hnorris-laptop ~ # docker-machine create --driver virtualbox worker5 +
-... +
-</code> +
- +
-Les options de la sous-commande **create** de la commande **docker-machine** sont : +
- +
-<code> +
-hnorris-laptop ~ # docker-machine create --help  +
-Usage: docker-machine create [OPTIONS] [arg...] +
- +
-Create a machine +
- +
-Description: +
-   Run 'docker-machine create --driver name' to include the create flags for that driver in the help text. +
- +
-Options: +
-    +
-   --driver, -d "virtualbox" Driver to create machine with. [$MACHINE_DRIVER] +
-   --engine-env [--engine-env option --engine-env option] Specify environment variables to set in the engine +
-   --engine-insecure-registry [--engine-insecure-registry option --engine-insecure-registry option] Specify insecure registries to allow with the created engine +
-   --engine-install-url "https://get.docker.com" Custom URL to use for engine installation [$MACHINE_DOCKER_INSTALL_URL] +
-   --engine-label [--engine-label option --engine-label option] Specify labels for the created engine +
-   --engine-opt [--engine-opt option --engine-opt option] Specify arbitrary flags to include with the created engine in the form flag=value +
-   --engine-registry-mirror [--engine-registry-mirror option --engine-registry-mirror option] Specify registry mirrors to use [$ENGINE_REGISTRY_MIRROR] +
-   --engine-storage-driver Specify a storage driver to use with the engine +
-   --swarm Configure Machine to join a Swarm cluster +
-   --swarm-addr addr to advertise for Swarm (default: detect and use the machine IP) +
-   --swarm-discovery Discovery service to use with Swarm +
-   --swarm-experimental Enable Swarm experimental features +
-   --swarm-host "tcp://0.0.0.0:3376" ip/socket to listen on for Swarm master +
-   --swarm-image "swarm:latest" Specify Docker image to use for Swarm [$MACHINE_SWARM_IMAGE] +
-   --swarm-join-opt [--swarm-join-opt option --swarm-join-opt option] Define arbitrary flags for Swarm join +
-   --swarm-master Configure Machine to be a Swarm master +
-   --swarm-opt [--swarm-opt option --swarm-opt option] Define arbitrary flags for Swarm master +
-   --swarm-strategy "spread" Define a default scheduling strategy for Swarm +
-   --tls-san [--tls-san option --tls-san option] Support extra SANs for TLS certs +
-   --virtualbox-boot2docker-url The URL of the boot2docker image. Defaults to the latest available version [$VIRTUALBOX_BOOT2DOCKER_URL] +
-   --virtualbox-cpu-count "1" number of CPUs for the machine (-1 to use the number of CPUs available) [$VIRTUALBOX_CPU_COUNT] +
-   --virtualbox-disk-size "20000" Size of disk for host in MB [$VIRTUALBOX_DISK_SIZE] +
-   --virtualbox-host-dns-resolver Use the host DNS resolver [$VIRTUALBOX_HOST_DNS_RESOLVER] +
-   --virtualbox-hostonly-cidr "192.168.99.1/24" Specify the Host Only CIDR [$VIRTUALBOX_HOSTONLY_CIDR] +
-   --virtualbox-hostonly-nicpromisc "deny" Specify the Host Only Network Adapter Promiscuous Mode [$VIRTUALBOX_HOSTONLY_NIC_PROMISC] +
-   --virtualbox-hostonly-nictype "82540EM" Specify the Host Only Network Adapter Type [$VIRTUALBOX_HOSTONLY_NIC_TYPE] +
-   --virtualbox-hostonly-no-dhcp Disable the Host Only DHCP Server [$VIRTUALBOX_HOSTONLY_NO_DHCP] +
-   --virtualbox-import-boot2docker-vm The name of a Boot2Docker VM to import [$VIRTUALBOX_BOOT2DOCKER_IMPORT_VM] +
-   --virtualbox-memory "1024" Size of memory for host in MB [$VIRTUALBOX_MEMORY_SIZE] +
-   --virtualbox-nat-nictype "82540EM" Specify the Network Adapter Type [$VIRTUALBOX_NAT_NICTYPE] +
-   --virtualbox-no-dns-proxy Disable proxying all DNS requests to the host [$VIRTUALBOX_NO_DNS_PROXY] +
-   --virtualbox-no-share Disable the mount of your home directory [$VIRTUALBOX_NO_SHARE] +
-   --virtualbox-no-vtx-check Disable checking for the availability of hardware virtualization before the vm is started [$VIRTUALBOX_NO_VTX_CHECK] +
-   --virtualbox-share-folder Mount the specified directory instead of the default home location. Format: dir:name [$VIRTUALBOX_SHARE_FOLDER] +
-   --virtualbox-ui-type "headless" Specify the UI Type: (gui|sdl|headless|separate) [$VIRTUALBOX_UI_TYPE] +
-</code>  +
- +
-====Lister les VM Docker==== +
- +
-Pour lister les VM Docker ainsi que leurs états, il convient d'utilise la sous-commande **ls** de la commande **docker-machine** : +
- +
-<code> +
-hnorris-laptop ~ # docker-machine ls +
-NAME       ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER        ERRORS +
-manager1          virtualbox   Running   tcp://192.168.99.100:2376           v17.06.2-ce    +
-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> +
- +
-<WRAP center round important> +
-**Important** - Si vous avez Windows 7 ou 8 et vous utilisez Docker Toolbox, les adresses IP des machines seront décalées de 1. Par exemple pour manager1, l'adresse sera 192.168.99.101 et pour worker1 192.168.99.102. Vous devez donc en tenir compte dans la suite du cours. +
-</WRAP> +
- +
-====Obtenir l'adresse IP des VM==== +
- +
-Une autre façon d'obtenir les adresses IP des VM est d'utiliser la sous-commande **ip** : +
- +
-<code> +
-hnorris-laptop ~ # docker-machine ip manager1 +
-192.168.99.100 +
-hnorris-laptop ~ # docker-machine ip worker1 +
-192.168.99.101 +
-hnorris-laptop ~ # docker-machine ip worker2 +
-192.168.99.102 +
-hnorris-laptop ~ # docker-machine ip worker3 +
-192.168.99.103 +
-hnorris-laptop ~ # docker-machine ip worker4 +
-192.168.99.104 +
-hnorris-laptop ~ # docker-machine ip worker5 +
-192.168.99.105 +
-</code> +
- +
-====Se connecter à une VM Docker==== +
- +
-Pour se connecter à une VM Docker, il convient d'utiliser la sous-commande **ssh** de la commande **docker-machine** : +
- +
-<code> +
-hnorris-laptop ~ # docker-machine ssh manager1 +
-                        ##         . +
-                  ## ## ##        == +
-               ## ## ## ## ##    === +
-           /"""""""""""""""""\___/ === +
-      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~ +
-           \______ o           __/ +
-                \         __/ +
-              \____\_______/ +
-                   ____                _ +
-| |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __ +
-| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__| +
-| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ | +
-|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_| +
-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:~$  +
-</code> +
- +
-<WRAP center round important> +
-**Important** - Notez que la distribution de la VM est **[[http://boot2docker.io/|Boot2Docker]]**. Cette distribution est basée sur **[[http://tinycorelinux.net/|Tiny Core Linux]]**, s'exécute entièrement dans la mémoire vive, pèse 27 Mo et démarre en approximativement 5 secondes. +
-</WRAP> +
- +
-Ayant été créées par root, les VM Docker ainsi que leurs fichiers associés sont stockés dans le répertoire **/root/.docker/machine/machines/** : +
- +
-<code> +
-hnorris-laptop ~ # 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> +
- +
-=====Docker Swarm===== +
- +
-====Présentation==== +
- +
-Docker Swarm est un utilitaire qui permet de gérer un cluster pour déployer des conteneurs en permettant une imitation du comportement de docker sur une seule machine.  +
- +
-====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> +
-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> +
- +
-====LAB #4 - Utiliser Docker Swarm==== +
- +
-===Le Statut Leader=== +
- +
-Consultez le statut de la VM Docker manager1 : +
- +
-<code> +
-docker@manager1:~$ docker node ls +
-ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS +
-yuwpmvtfmdxn8i7nllkyzkxkp *   manager1            Ready               Active              Leader +
-</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. +
- +
-Pour connaître le token nécessaire pour rejoindre swarm en tant que nœud de gestion, saisissez la commande suivante : +
- +
-<code> +
-docker@manager1:~$ docker swarm join-token manager +
-To add a manager to this swarm, run the following command: +
- +
-    docker swarm join --token SWMTKN-1-5bd9w9tapfqmd41f2psqdkoqwfo48fqsznnalk2slc28vlp6uh-8rvbxvqewsrv6yyts7z2lq9pt 192.168.99.100:2377 +
-</code> +
- +
-===Rejoindre le Swarm=== +
- +
-Rejoignez les 5 machines travailleurs à swarm en utilisant le token **worker** : +
- +
-<code> +
-docker@worker1:~$ docker swarm join --token SWMTKN-1-5bd9w9tapfqmd41f2psqdkoqwfo48fqsznnalk2slc28vlp6uh-004kp8y71m09nd7p8ft7ldku0 192.168.99.100:2377 +
-This node joined a swarm as a worker. +
-</code> +
- +
-<code> +
-docker@worker2:~$ docker swarm join --token SWMTKN-1-5bd9w9tapfqmd41f2psqdkoqwfo48fqsznnalk2slc28vlp6uh-004kp8y71m09nd7p8ft7ldku0 192.168.99.100:2377 +
-This node joined a swarm as a worker. +
-</code> +
- +
-<code> +
-docker@worker3:~$ docker swarm join --token SWMTKN-1-5bd9w9tapfqmd41f2psqdkoqwfo48fqsznnalk2slc28vlp6uh-004kp8y71m09nd7p8ft7ldku0 192.168.99.100:2377 +
-This node joined a swarm as a worker. +
-</code> +
- +
-<code> +
-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> +
-docker@worker5:~$ docker swarm join --token SWMTKN-1-5bd9w9tapfqmd41f2psqdkoqwfo48fqsznnalk2slc28vlp6uh-004kp8y71m09nd7p8ft7ldku0 192.168.99.100:2377 +
-This node joined a swarm as a worker. +
-</code> +
- +
-L'état des VM Docker peut être consulter en utilisant de nouveau la commande **docker node ls** : +
- +
-<code> +
-docker@manager1:~$ docker node ls +
-ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS +
-1f5qtolgtonqmhjk5ppwc8x1b     worker1             Ready               Active               +
-kmyjdwp9ojhzje4hlw7ffhuxv     worker2             Ready               Active               +
-oyszb44k8yw5btz3c1wq2ot2e     worker4             Ready               Active               +
-p6jpyopzzy0zg4znegi63hzjq     worker5             Ready               Active               +
-yitkfnk99ecisrny9g3r9kfhk     worker3             Ready               Active               +
-yuwpmvtfmdxn8i7nllkyzkxkp *   manager1            Ready               Active              Leader +
-</code> +
- +
-Notez que vous ne pouvez pas utiliser cette commande à partir d'un travailleur : +
- +
-<code> +
-docker@worker5:~$ docker node ls +
-Error response from daemon: This node is not a swarm manager. Worker nodes can't be used to view or modify cluster state. Please run this command on a manager node or promote the current node to a manager. +
-</code> +
- +
-===Consulter les Informations de Swarm=== +
- +
-Il est possible de visualiser les informations concernant le swarm en utilisant la commande **docker info** : +
- +
-<code> +
-docker@manager1:~$ docker info +
-... +
-Swarm: active +
- NodeID: yuwpmvtfmdxn8i7nllkyzkxkp +
- Is Manager: true +
- ClusterID: sqll9xmii9qkrd35d1limn1od +
- Managers:+
- Nodes:+
- Orchestration: +
-  Task History Retention Limit: 5 +
- 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> +
-**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> +
- +
-===Démarrer un Service=== +
- +
-Dans cet exemple, nous allons démarrer le service **nginx** avec les propriétés suivantes : +
- +
-  * Mappage du port nginx sur le port 80 de la machine hôte, +
-  * 5 instances du service, +
-  * Un nom unique de **web**. +
- +
-<code> +
-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** : +
- +
-<code> +
-docker@manager1:~$ docker service ls +
-ID                  NAME                MODE                REPLICAS            IMAGE               PORTS +
-4xtuwgbvr17l        web                 replicated          5/5                 nginx:latest        *:80->80/tcp +
-</code> +
- +
-Ce service fonctionne dans des conteneurs Docker : +
- +
-<code> +
-docker@manager1:~$ docker service ps web +
-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> +
-**Important** - Notez qu'il n'y a pas de conteneur sur worker5. +
-</WRAP> +
- +
-Pour constater le lancement du daemon nginx, lancez la commande **docker ps** sur la machine **manager1** : +
- +
-<code> +
-docker@manager1:~$ docker ps +
-CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES +
-4107cb687eda        nginx:latest        "nginx -g 'daemon ..."   2 minutes ago       Up 2 minutes        80/tcp              web.3.imqdkw4ei6gskwacnb4pime5f +
-</code> +
- +
-Connectez-vous sur chaque VM Docker pour constater que le service nginx fonctionne : +
- +
-<code> +
-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 +
-workingFurther configuration is required.</p> +
- +
-<p>For online documentation and support please refer to +
-<a href="http://nginx.org/">nginx.org</a>.<br/> +
-Commercial support is available at +
-<a href="http://nginx.com/">nginx.com</a>.</p> +
- +
-<p><em>Thank you for using nginx.</em></p> +
-</body> +
-</html> +
-docker@manager1:/$ curl 192.168.99.101 +
-<!DOCTYPE html> +
-<html> +
-<head> +
-<title>Welcome to nginx!</title> +
-<style> +
-    body { +
-        width: 35em; +
-        margin: 0 auto; +
-        font-family: Tahoma, Verdana, Arial, sans-serif; +
-    } +
-</style> +
-</head> +
-<body> +
-<h1>Welcome to nginx!</h1> +
-<p>If you see this page, the nginx web server is successfully installed and +
-working. Further configuration is required.</p> +
- +
-<p>For online documentation and support please refer to +
-<a href="http://nginx.org/">nginx.org</a>.<br/> +
-Commercial support is available at +
-<a href="http://nginx.com/">nginx.com</a>.</p> +
- +
-<p><em>Thank you for using nginx.</em></p> +
-</body> +
-</html> +
-docker@manager1:/$ curl 192.168.99.102 +
-<!DOCTYPE html> +
-<html> +
-<head> +
-<title>Welcome to nginx!</title> +
-<style> +
-    body { +
-        width: 35em; +
-        margin: 0 auto; +
-        font-family: Tahoma, Verdana, Arial, sans-serif; +
-    } +
-</style> +
-</head> +
-<body> +
-<h1>Welcome to nginx!</h1> +
-<p>If you see this page, the nginx web server is successfully installed and +
-working. Further configuration is required.</p> +
- +
-<p>For online documentation and support please refer to +
-<a href="http://nginx.org/">nginx.org</a>.<br/> +
-Commercial support is available at +
-<a href="http://nginx.com/">nginx.com</a>.</p> +
- +
-<p><em>Thank you for using nginx.</em></p> +
-</body> +
-</html> +
-docker@manager1:/$ curl 192.168.99.103 +
-<!DOCTYPE html> +
-<html> +
-<head> +
-<title>Welcome to nginx!</title> +
-<style> +
-    body { +
-        width: 35em; +
-        margin: 0 auto; +
-        font-family: Tahoma, Verdana, Arial, sans-serif; +
-    } +
-</style> +
-</head> +
-<body> +
-<h1>Welcome to nginx!</h1> +
-<p>If you see this page, the nginx web server is successfully installed and +
-working. Further configuration is required.</p> +
- +
-<p>For online documentation and support please refer to +
-<a href="http://nginx.org/">nginx.org</a>.<br/> +
-Commercial support is available at +
-<a href="http://nginx.com/">nginx.com</a>.</p> +
- +
-<p><em>Thank you for using nginx.</em></p> +
-</body> +
-</html> +
-docker@manager1:/$ curl 192.168.99.104 +
-<!DOCTYPE html> +
-<html> +
-<head> +
-<title>Welcome to nginx!</title> +
-<style> +
-    body { +
-        width: 35em; +
-        margin: 0 auto; +
-        font-family: Tahoma, Verdana, Arial, sans-serif; +
-    } +
-</style> +
-</head> +
-<body> +
-<h1>Welcome to nginx!</h1> +
-<p>If you see this page, the nginx web server is successfully installed and +
-working. Further configuration is required.</p> +
- +
-<p>For online documentation and support please refer to +
-<a href="http://nginx.org/">nginx.org</a>.<br/> +
-Commercial support is available at +
-<a href="http://nginx.com/">nginx.com</a>.</p> +
- +
-<p><em>Thank you for using nginx.</em></p> +
-</body> +
-</html> +
-docker@manager1:/$ curl 192.168.99.105 +
-<!DOCTYPE html> +
-<html> +
-<head> +
-<title>Welcome to nginx!</title> +
-<style> +
-    body { +
-        width: 35em; +
-        margin: 0 auto; +
-        font-family: Tahoma, Verdana, Arial, sans-serif; +
-    } +
-</style> +
-</head> +
-<body> +
-<h1>Welcome to nginx!</h1> +
-<p>If you see this page, the nginx web server is successfully installed and +
-working. Further configuration is required.</p> +
- +
-<p>For online documentation and support please refer to +
-<a href="http://nginx.org/">nginx.org</a>.<br/> +
-Commercial support is available at +
-<a href="http://nginx.com/">nginx.com</a>.</p> +
- +
-<p><em>Thank you for using nginx.</em></p> +
-</body> +
-</html> +
-</code> +
- +
-<WRAP center round important> +
-**Important** - Notez que le service est même disponible en consultant l'adresse IP de worker5. +
-</WRAP> +
- +
-===Augmentation et Réduction du Service=== +
- +
-Actuellement, il existe 5 conteneurs en cours d'exécution. Pour procéder à un scale-up à 8 conteneurs, il convient d'utiliser la commande **docker service scale** : +
- +
-<code> +
-docker@manager1:/$ docker service scale web=8 +
-web scaled to 8 +
-</code> +
- +
-Notez que la commande **docker service ls** confirme le fait qu'il y a 8 replicas : +
- +
-<code> +
-docker@manager1:/$ docker service ls +
-ID                  NAME                MODE                REPLICAS            IMAGE               PORTS +
-4xtuwgbvr17l        web                 replicated          8/8                 nginx:latest        *:80->80/tcp +
-</code> +
- +
-Des trois replicas supplémentaires, deux ont été lancés sur worker5 tandis que le troisième a été lancé sur worker1 : +
- +
-<code> +
-docker@manager1:/$ docker service ps web +
-ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE            ERROR               PORTS +
-jkm2hapcthht        web.1               nginx:latest        worker3             Running             Running 20 minutes ago                        +
-q55eqdhr1qf1        web.2               nginx:latest        worker4             Running             Running 20 minutes ago                        +
-imqdkw4ei6gs        web.3               nginx:latest        manager1            Running             Running 20 minutes ago                        +
-k4vjd0g7ijww        web.4               nginx:latest        worker1             Running             Running 20 minutes ago                        +
-b7xbmy1npgf9        web.5               nginx:latest        worker2             Running             Running 20 minutes ago                        +
-kg3bivcg0wln        web.6               nginx:latest        worker5             Running             Running 47 seconds ago                        +
-ik3u0jfgey64        web.7               nginx:latest        worker5             Running             Running 47 seconds ago                        +
-6bw5ptw7xao8        web.8               nginx:latest        worker1             Running             Running 57 seconds ago  +
-</code> +
- +
-===Consulter le Statut d'un Noeud=== +
- +
-Pour se renseigner sur le statut du nœud courant, il convient d'utiliser la commande **docker node inspect** avec le mot clef **self** : +
- +
-<code> +
-docker@manager1:/$ docker node inspect self +
-+
-    { +
-        "ID": "yuwpmvtfmdxn8i7nllkyzkxkp", +
-        "Version":+
-            "Index":+
-        }, +
-        "CreatedAt": "2017-09-08T11:43:55.289178512Z", +
-        "UpdatedAt": "2017-09-08T11:43:55.89870884Z", +
-        "Spec":+
-            "Labels": {}, +
-            "Role": "manager", +
-            "Availability": "active" +
-        }, +
-        "Description":+
-            "Hostname": "manager1", +
-            "Platform":+
-                "Architecture": "x86_64", +
-                "OS": "linux" +
-            }, +
-            "Resources":+
-                "NanoCPUs": 1000000000, +
-                "MemoryBytes": 1044123648 +
-            }, +
-            "Engine":+
-                "EngineVersion": "17.06.2-ce", +
-                "Labels":+
-                    "provider": "virtualbox" +
-                }, +
-                "Plugins":+
-                    { +
-                        "Type": "Log", +
-                        "Name": "awslogs" +
-                    }, +
-                    { +
-                        "Type": "Log", +
-                        "Name": "fluentd" +
-                    }, +
-                    { +
-                        "Type": "Log", +
-                        "Name": "gcplogs" +
-                    }, +
-                    { +
-                        "Type": "Log", +
-                        "Name": "gelf" +
-                    }, +
-                    { +
-                        "Type": "Log", +
-                        "Name": "journald" +
-                    }, +
-                    { +
-                        "Type": "Log", +
-                        "Name": "json-file" +
-                    }, +
-                    { +
-                        "Type": "Log", +
-                        "Name": "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":+
-            "State": "ready", +
-            "Addr": "192.168.99.100" +
-        }, +
-        "ManagerStatus":+
-            "Leader": true, +
-            "Reachability": "reachable", +
-            "Addr": "192.168.99.100:2377" +
-        } +
-    } +
-+
- +
-</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é : +
- +
-<code> +
-docker@manager1:/$ docker node inspect worker1 +
-+
-    { +
-        "ID": "1f5qtolgtonqmhjk5ppwc8x1b", +
-        "Version":+
-            "Index": 15 +
-        }, +
-        "CreatedAt": "2017-09-08T11:48:42.011596185Z", +
-        "UpdatedAt": "2017-09-08T11:48:42.093455479Z", +
-        "Spec":+
-            "Labels": {}, +
-            "Role": "worker", +
-            "Availability": "active" +
-        }, +
-        "Description":+
-            "Hostname": "worker1", +
-            "Platform":+
-                "Architecture": "x86_64", +
-                "OS": "linux" +
-            }, +
-            "Resources":+
-                "NanoCPUs": 1000000000, +
-                "MemoryBytes": 1044123648 +
-            }, +
-            "Engine":+
-                "EngineVersion": "17.06.2-ce", +
-                "Labels":+
-                    "provider": "virtualbox" +
-                }, +
-                "Plugins":+
-                    { +
-                        "Type": "Log", +
-                        "Name": "awslogs" +
-                    }, +
-                    { +
-                        "Type": "Log", +
-                        "Name": "fluentd" +
-                    }, +
-                    { +
-                        "Type": "Log", +
-                        "Name": "gcplogs" +
-                    }, +
-                    { +
-                        "Type": "Log", +
-                        "Name": "gelf" +
-                    }, +
-                    { +
-                        "Type": "Log", +
-                        "Name": "journald" +
-                    }, +
-                    { +
-                        "Type": "Log", +
-                        "Name": "json-file" +
-                    }, +
-                    { +
-                        "Type": "Log", +
-                        "Name": "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":+
-            "State": "ready", +
-            "Addr": "192.168.99.101" +
-        } +
-    } +
-+
-</code> +
- +
-L'option **--pretty** produit une sortie plus facilement lisible : +
- +
-<code> +
-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> +
- +
-===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> +
-docker@manager1:/$ docker node ls +
-ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS +
-1f5qtolgtonqmhjk5ppwc8x1b     worker1             Ready               Active               +
-kmyjdwp9ojhzje4hlw7ffhuxv     worker2             Ready               Active               +
-oyszb44k8yw5btz3c1wq2ot2e     worker4             Ready               Active               +
-p6jpyopzzy0zg4znegi63hzjq     worker5             Ready               Active               +
-yitkfnk99ecisrny9g3r9kfhk     worker3             Ready               Active               +
-yuwpmvtfmdxn8i7nllkyzkxkp *   manager1            Ready               Active              Leader +
-</code> +
- +
-et que sur les 6 VM Docker, il y a 8 conteneurs, +
- +
-<code> +
-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 : +
- +
-<code> +
-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> +
-docker@manager1:/$ docker node update --availability drain worker1 +
-worker1 +
-</code> +
- +
-Constatez que le service web a été déplacé sur deux autres noeuds, **manager1** et **worker4** : +
- +
-<code> +
-docker@manager1:/$ docker service ps web +
-ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE             ERROR               PORTS +
-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.6               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> +
- +
-===Supprimer un Service=== +
- +
-Pour supprimer un service il convient d'utiliser la commande **docker service rm** +
- +
-<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> +
- +
------ +
-<html> +
-<div align="center"> +
-Copyright © 2020 Hugh NORRIS +
-</div> +
-</html>+
Menu