Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| elearning:workbooks:docker1:dfr00 [2020/07/28 12:00] – admin | elearning:workbooks:docker1:dfr00 [2021/12/29 10:32] (Version actuelle) – admin | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| ~~PDF: | ~~PDF: | ||
| - | Version : **2020.01** | + | Version : **2022.01** |
| Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
| - | ======DOF101 - Démarrer avec Docker====== | + | ======DOF101 - La Virtualisation par Isolation====== |
| =====Contenu du Module===== | =====Contenu du Module===== | ||
| - | * **DOF101 - Démarrer avec Docker** | + | * **DOF101 - La Virtualisation par Isolation** |
| - | * LAB #1 - Utilisation | + | * Contenu du Module |
| - | * Formations en Face-à-Face Pédagogique (FFP) | + | * Présentation |
| - | * Formations à Distance (FAD) | + | * Historique |
| - | * Linux, MacOS et Windows 10 muni du client ssh | + | * Présentation des Namespaces |
| - | * Windows 7 et Windows 10 sans client ssh | + | * Présentation des CGroups |
| - | * Lancement | + | * LAB #1 - Travailler avec les CGroups |
| - | * Connexion à la Machine Virtuelle | + | * 1.1 - Limitation |
| - | * Linux, MacOS, Windows 10 muni du client ssh et FAD | + | * 1.2 - Le Paquet cgroup-tools |
| - | * Windows 7 et Windows 10 sans client ssh en FFP | + | * La commande cgcreate |
| - | * LAB #2 - Installation de Docker-CE | + | * La Commande cgexec |
| - | * Présentation de la virtualisation | + | * La Commande cgdelete |
| - | * Présentation de Docker | + | * Le Fichier / |
| - | | + | * Présentation de Linux Containers |
| - | | + | * LAB #2 - Travailler |
| - | * Démarrer un Conteneur | + | * 2.1 - Installation |
| - | * Consulter la Liste des Conteneurs et Images | + | * 2.2 - Création d'un Conteneur Simple |
| - | * Rechercher une Image dans un Dépôt | + | * 2.3 - Démarrage d'un Conteneur |
| - | * Supprimer | + | * 2.4 - S'attacher à un Conteneur |
| - | * Créer une Image à partir d'un Conteneur | + | * 2.5 - Commandes LXC de Base |
| - | * Supprimer une Image | + | * La Commande lxc-console |
| - | * Créer un Conteneur avec un Nom Specific | + | * La Commande |
| - | * Exécuter une Commande | + | * La Commande lxc-execute |
| - | * Injecter des Variables d' | + | * La Commande lxc-info |
| - | * Modifier le Nom d' | + | * La Commande lxc-freeze |
| - | * Mapper des Ports d'un Conteneur | + | * La Commande lxc-unfreeze |
| - | * Démarrer un Conteneur en mode Détaché | + | * Autres commandes |
| - | * Accéder aux Services | + | |
| - | * Arrêter et Démarrer un Conteneur | + | * User Namespaces |
| - | * Utiliser des Signaux avec un Conteneur | + | * Création |
| - | * Forcer la Suppression d'un Conteneur en cours d' | + | * Création du Mappage |
| - | * Utilisation Simple | + | * Création du Conteneur |
| - | * Télécharger une image sans créer un conteneur | + | * Contrôle du Mappage |
| - | * S' | + | * 2.7 - Création |
| - | * Installer un logiciel dans le conteneur | + | * La Commande lxc-copy |
| - | * Utilisation de la commande docker commit | + | * 2.8 - Sauvegarde des Conteneurs |
| - | * Se connecter au serveur du conteneur de l' | + | * La Commande lxc-snapshot |
| - | =====LAB #1 - Utilisation | + | =====Présentation |
| - | + | ||
| - | ====Formations en Face-à-Face Pédagogique (FFP) ==== | + | |
| - | + | ||
| - | Si vous suivez cette formation en Centre de Formation, vous avez besoin d' | + | |
| - | + | ||
| - | Ouvrez VirtualBox et importez la machine virtuelle **Debian_9** : | + | |
| - | + | ||
| - | Fichier > Importer un appareil virtuel ... | + | |
| - | + | ||
| - | La machine virtuelle a été configurée ainsi : | + | |
| - | + | ||
| - | ^ Machine ^ Nom d' | + | |
| - | | Debian_9 | debian9 | 10.0.2.15 | 2022 | | + | |
| - | + | ||
| - | Démarrez ensuite la machine virtuelle **Debian_9**. | + | |
| - | + | ||
| - | ====Formations à Distance (FAD) ==== | + | |
| - | + | ||
| - | Vous disposez d'un serveur dédié, pré-installé, | + | |
| - | + | ||
| - | Connectez-vous en ssh à votre serveur dédié : | + | |
| - | + | ||
| - | ===Linux, MacOS et Windows 10 muni du client ssh=== | + | |
| - | + | ||
| - | Ouvrez un terminal ou CMD et tapez la commande suivante : | + | |
| - | + | ||
| - | < | + | |
| - | $ ssh -l desktop serverXX.ittraining.network | + | |
| - | </ | + | |
| - | + | ||
| - | où **XX** représente le numéro de votre serveur dédié. Entrez ensuite le mot de passe qui vous a été fourni. | + | |
| - | + | ||
| - | ===Windows 7 et Windows 10 sans client ssh=== | + | |
| - | + | ||
| - | Ouvrez **putty** et utilisez les informations suivantes pour vous connecter à votre serveur dédié : | + | |
| - | + | ||
| - | * Host Name --> serverXX.ittraining.network | + | |
| - | * Port --> 22 | + | |
| - | + | ||
| - | Au prompt, connectez-vous en tant que **desktop** avec le mot de passe qui vous a été fourni. | + | |
| - | + | ||
| - | ===Lancement de la Machine Virtuelle Debian_9=== | + | |
| - | + | ||
| - | La machine virtuelle a été configurée ainsi : | + | |
| - | + | ||
| - | ^ Machine ^ Nom d' | + | |
| - | | Debian_9 | debian9 | 10.0.2.15 | 2022 | | + | |
| - | + | ||
| - | Pour lancer la machine **Debian_9**, | + | |
| - | + | ||
| - | < | + | |
| - | desktop@serverXX: | + | |
| - | Waiting for VM " | + | |
| - | VM " | + | |
| - | </ | + | |
| - | + | ||
| - | ====Connexion à la Machine Virtuelle==== | + | |
| - | + | ||
| - | Les noms d' | + | |
| - | + | ||
| - | ^ Utilisateur ^ Mot de Passe ^ | + | |
| - | | trainee | trainee | | + | |
| - | | root | fenestros | | + | |
| - | + | ||
| - | Vous devez vous connecter à la machine virtuelle **Debian_9** d'une des deux façons suivantes : | + | |
| - | + | ||
| - | ===Linux, MacOS, Windows 10 muni du client ssh et FAD=== | + | |
| - | + | ||
| - | Ouvrez un terminal et tapez la commande suivante pour vous connecter à la machine **Debian_9** : | + | |
| - | + | ||
| - | < | + | |
| - | $ ssh -l trainee localhost -p 2022 | + | |
| - | </ | + | |
| - | + | ||
| - | ===Windows 7 et Windows 10 sans client ssh en FFP=== | + | |
| - | + | ||
| - | Ouvrez **putty** et utilisez les informations suivantes pour vous connecter à **Debian_9** : | + | |
| - | + | ||
| - | * Host Name --> localhost | + | |
| - | * Port --> 2022 | + | |
| - | + | ||
| - | =====La | + | |
| Un isolateur est un logiciel qui permet d' | Un isolateur est un logiciel qui permet d' | ||
| Ligne 139: | Ligne 57: | ||
| * **2004** - [[https:// | * **2004** - [[https:// | ||
| * **2005** - [[https:// | * **2005** - [[https:// | ||
| - | * **2008** - [[https:// | + | * **2008** - [[https:// |
| - | * **2013** - [[https:// | + | * **2013** - [[https:// |
| - | * **2014** - [[https:// | + | * **2014** - [[https:// |
| =====Présentation des Namespaces===== | =====Présentation des Namespaces===== | ||
| Ligne 151: | Ligne 69: | ||
| Les Groupes de Contrôles (Control Groups) aussi appelés **CGroups**, | Les Groupes de Contrôles (Control Groups) aussi appelés **CGroups**, | ||
| - | Les CGroups sont organisés de manière hiérarchique, | + | Les CGroups sont organisés de manière hiérarchique, |
| Ces hiérarchies multiples et séparés sont necéssaires parce que chaque hiérarchie est attaché à un ou plusieurs sous-système(s) aussi appelés des **Contrôleurs de Ressources** ou simplement des **Contrôleurs**. Les contrôleurs disponibles sont : | Ces hiérarchies multiples et séparés sont necéssaires parce que chaque hiérarchie est attaché à un ou plusieurs sous-système(s) aussi appelés des **Contrôleurs de Ressources** ou simplement des **Contrôleurs**. Les contrôleurs disponibles sont : | ||
| Ligne 158: | Ligne 76: | ||
| * **cpu** - utilisé pour fournir aux tâches des groupes de contrôle accès au CPU grâce au planificateur, | * **cpu** - utilisé pour fournir aux tâches des groupes de contrôle accès au CPU grâce au planificateur, | ||
| * **cpuacct** - utilisé pour produire des rapports automatiques sur les ressources CPU utilisées par les tâches dans un groupe de contrôle, | * **cpuacct** - utilisé pour produire des rapports automatiques sur les ressources CPU utilisées par les tâches dans un groupe de contrôle, | ||
| - | * **cpuset** - utilisé pour assigner des CPU individuels sur un système | + | * **cpuset** - utilisé pour assigner des CPU individuels sur un système |
| * **devices** - utilisé pour autoriser ou pour refuser l' | * **devices** - utilisé pour autoriser ou pour refuser l' | ||
| * **freezer** - utilisé pour suspendre ou pour réactiver les tâches dans un groupe de contrôle, | * **freezer** - utilisé pour suspendre ou pour réactiver les tâches dans un groupe de contrôle, | ||
| Ligne 270: | Ligne 188: | ||
| En utilisant Systemd, plusieurs ressources peuvent être limitées : | En utilisant Systemd, plusieurs ressources peuvent être limitées : | ||
| - | * **CPUShares** - par défault | + | * **CPUShares** - par défaut |
| * **MemoryLimit** - limite exprimée en Mo ou en Go. Pas de valeur par défaut, | * **MemoryLimit** - limite exprimée en Mo ou en Go. Pas de valeur par défaut, | ||
| * **BlockIOWeight** - valeur entre 10 et 1000. Pas de valeur par défaut, | * **BlockIOWeight** - valeur entre 10 et 1000. Pas de valeur par défaut, | ||
| Ligne 281: | Ligne 199: | ||
| </ | </ | ||
| - | ====LAB #2 - Travailler avec les CGroups==== | + | ====LAB #1 - Travailler avec les CGroups==== |
| + | |||
| + | ===1.1 - Limitation de la Mémoire=== | ||
| Pour travailler avec les CGroups dans Debian 9, il convient d' | Pour travailler avec les CGroups dans Debian 9, il convient d' | ||
| Ligne 426: | Ligne 346: | ||
| </ | </ | ||
| - | ===Le Paquet cgroup-tools=== | + | ===1.2 - Le Paquet cgroup-tools=== |
| Le paquet **cgroup-tools** installe des commandes dites //de facilité// dont : | Le paquet **cgroup-tools** installe des commandes dites //de facilité// dont : | ||
| Ligne 502: | Ligne 422: | ||
| </ | </ | ||
| - | ==La Commande cgexec== | + | ==Le Fichier / |
| - | Afin de les rendre | + | Afin de les rendre |
| < | < | ||
| Ligne 590: | Ligne 510: | ||
| </ | </ | ||
| - | =====Linux Containers===== | + | =====Présentation de Linux Containers===== |
| - | ====Installation==== | + | ====LAB #2 - Travailler avec LXC==== |
| + | |||
| + | ===2.1 - Installation=== | ||
| Les outils indispensables à l' | Les outils indispensables à l' | ||
| Ligne 617: | Ligne 539: | ||
| </ | </ | ||
| - | ====LAB #3 - Travailler avec LXC==== | + | ===2.2 - Création d'un Conteneur Simple=== |
| - | + | ||
| - | ===Création d'un Conteneur Simple=== | + | |
| - | Créez un conteneur simple en utilsant | + | Créez un conteneur simple en utilisant |
| < | < | ||
| Ligne 634: | Ligne 554: | ||
| </ | </ | ||
| - | Le **backingstore** (// méthode de stockage//) utilisé par défaut est **dir** ce qui implqiue | + | Le **backingstore** (// méthode de stockage//) utilisé par défaut est **dir** ce qui implique |
| < | < | ||
| Ligne 655: | Ligne 575: | ||
| * rbd (CephFS) | * rbd (CephFS) | ||
| - | ===Démarrage d'un Conteneur Simple=== | + | ===2.3 - Démarrage d'un Conteneur Simple=== |
| Pour démarrer le conteneur, il convient d' | Pour démarrer le conteneur, il convient d' | ||
| Ligne 663: | Ligne 583: | ||
| </ | </ | ||
| - | ===S' | + | ===2.4 - S' |
| Pour s' | Pour s' | ||
| Ligne 702: | Ligne 622: | ||
| </ | </ | ||
| - | ===Commandes LXC de Base=== | + | ===2.5 - Commandes LXC de Base=== |
| ==La Commande lxc-console== | ==La Commande lxc-console== | ||
| Ligne 798: | Ligne 718: | ||
| </ | </ | ||
| - | ==La Commande lxc-freeze== | + | ==La Commande lxc-unfreeze== |
| La commande **lxc-unfreeze** annule l' | La commande **lxc-unfreeze** annule l' | ||
| Ligne 815: | Ligne 735: | ||
| </ | </ | ||
| - | root@debian9: | + | ==Autres Commandes== |
| - | > # | + | |
| - | > while [ 1 ]; do | + | |
| - | > echo " | + | |
| - | > sleep 1 | + | |
| - | > done | + | |
| - | > EOF | + | |
| - | ~ # sh ./hi.sh & | + | Les autres commandes dont il faut avoir une connaissance sont : |
| - | ~ # Hi | + | |
| - | Hi | + | |
| - | Hi | + | |
| - | Hi | + | |
| - | Hi | + | |
| - | Hi | + | |
| - | 2ième terminal | + | ^ Commande ^ Description ^ |
| + | | lxc-destroy | Permet de détruire complètement un conteneur | | ||
| + | | lxc-autostart | Permet de rebooter, tuer ou arrêter les conteneurs dont le drapeau **lxc.start.auto** est fixé dans le fichier **/ | ||
| + | | lxc-cgroup | Permet de manipuler à chaud les CGroups pour un conteneur donné | | ||
| + | | lxc-device | Permet de rajouter à chaud les devices à un conteneur | | ||
| + | | lxc-usernsexec | Permet d' | ||
| + | | lxc-wait | Permet d' | ||
| - | $ ssh -l trainee -p 2022 localhost | + | ===2.6 |
| - | trainee@localhost's password: trainee | + | |
| - | Linux debian9 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 | + | |
| - | The programs included with the Debian GNU/Linux system are free software; | + | ==User Namespaces== |
| - | 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 | + | Un conteneur privilégié est un conteneur lancé par l' |
| - | permitted by applicable law. | + | |
| - | Last login: Sun Jul 26 09:39:03 2020 from 10.0.2.2 | + | |
| - | trainee@debian9: | + | |
| - | Mot de passe : fenestros | + | |
| - | root@debian9:~# lxc-freeze -n lxc-bb | + | |
| - | root@debian9:~# lxc-info -n lxc-bb | + | |
| - | Name: | + | |
| - | State: | + | |
| - | PID: 3906 | + | |
| - | CPU use: 0.16 seconds | + | |
| - | BlkIO use: 0 bytes | + | |
| - | Memory use: 1.24 MiB | + | |
| - | KMem use: | + | |
| - | root@debian9: | + | |
| - | root@debian9: | + | Le mappage d'UID est une fonctionnalité du noyau Linux appelée |
| - | root@debian9: | + | |
| - | Name: | + | |
| - | State: | + | |
| - | PID: 3906 | + | |
| - | CPU use: 0.16 seconds | + | |
| - | BlkIO use: 0 bytes | + | |
| - | Memory use: 1.25 MiB | + | |
| - | KMem use: | + | |
| - | + | ||
| - | root@debian9: | + | |
| - | 9223372036854771712 | + | |
| - | + | ||
| - | root@debian9: | + | |
| - | lxc-cgroup: tools/ | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | ===Présentation de Docker=== | + | |
| - | + | ||
| - | Docker | + | |
| - | + | ||
| - | Une **image** est un paquet exécutable contenant tout ce qu'il est necessaire afin d' | + | |
| - | + | ||
| - | * le code | + | |
| - | * un runtime | + | |
| - | * des bibliothèques, | + | |
| - | * des variables d' | + | |
| - | * des fichiers | + | |
| - | + | ||
| - | Un **conteneur** est une instance de l' | + | |
| - | + | ||
| - | Les conteneurs exécutent des applications nativement en utilisant le noyau de la machine hôte. De ce fait les performances d'un conteneur sont supérieures à celles d'une machine virtuelle qui doit passer par un hyperviseur pour accéder aux ressources | + | |
| - | + | ||
| - | Docker existe en deux versions **Docker-CE** (Docker Community Edition) et **Docker-EE** (Docker Enterprise Edition). Pour consulter les différences entre les deux versions, consultez le lien **[[https:// | + | |
| - | + | ||
| - | =====LAB #4 - Démarrer avec Docker===== | + | |
| - | ====1.1 - Installer docker==== | + | ==Création d'un Utilisateur Dédié== |
| - | Docker n'est pas dans le dépôts de Debian. Afin de l' | + | Commencez par créer |
| < | < | ||
| - | root@debian9: | + | root@debian9: |
| - | ... | + | root@debian9: |
| - | root@debian9: | + | Entrez le nouveau mot de passe UNIX : trainee |
| - | Reading package lists... Done | + | Retapez le nouveau mot de passe UNIX : trainee |
| - | Building dependency tree | + | passwd: password updated successfully |
| - | Reading state information... Done | + | |
| - | ca-certificates is already the newest version. | + | |
| - | ca-certificates set to manually installed. | + | |
| - | gnupg2 is already the newest version. | + | |
| - | gnupg2 set to manually installed. | + | |
| - | The following extra packages will be installed: | + | |
| - | | + | |
| - | Suggested packages: | + | |
| - | | + | |
| - | The following NEW packages will be installed: | + | |
| - | apt-transport-https curl libcurl3 python3-dbus python3-software-properties | + | |
| - | software-properties-common unattended-upgrades | + | |
| - | 0 upgraded, 7 newly installed, 0 to remove and 1 not upgraded. | + | |
| - | Need to get 960 kB of archives. | + | |
| - | After this operation, 2,344 kB of additional disk space will be used. | + | |
| - | Do you want to continue? [Y/n] | + | |
| </ | </ | ||
| - | Téléchargez la clef GPG officielle de docker | + | Les informations concernant le mappage des UID et GID se trouvent dans les fichiers **/ |
| < | < | ||
| - | root@debian9: | + | root@debian9: |
| - | OK | + | /etc/subuid:lxcnp: |
| - | </ | + | /etc/subgid:lxcnp:165536:65536 |
| - | + | ||
| - | Vérifiez que l'ID de la clef est **9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88** | + | |
| - | + | ||
| - | < | + | |
| - | root@debian9:~# apt-key fingerprint 0EBFCD88 | + | |
| - | /etc/apt/ | + | |
| - | -------------------- | + | |
| - | pub | + | |
| - | Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 | + | |
| - | uid Docker Release (CE deb) < | + | |
| - | sub | + | |
| - | ... | + | |
| - | </ | + | |
| - | + | ||
| - | Ajoutez le dépôt **stable** de docker | + | |
| - | + | ||
| - | < | + | |
| - | root@debian9:~# add-apt-repository "deb [arch=amd64] https:// | + | |
| </ | </ | ||
| <WRAP center round important> | <WRAP center round important> | ||
| - | **Important** - Notez que la commande **lsb_release -cs** retourne | + | **Important** - Ces informations indiquent |
| </ | </ | ||
| - | Installez maintenant le paquet **docker-ce** : | + | ==Création du Mappage== |
| - | < | + | La valeur de **kernel.unprivileged_userns_clone** doit être **1**, or actuellement elle est de **0** : |
| - | root@debian9: | + | |
| - | ... | + | |
| - | root@debian9: | + | |
| - | Reading package lists... Done | + | |
| - | Building dependency tree | + | |
| - | Reading state information... Done | + | |
| - | The following extra packages will be installed: | + | |
| - | aufs-tools cgroupfs-mount git git-man libapparmor1 liberror-perl | + | |
| - | libnih-dbus1 libnih1 makedev mountall plymouth rsync | + | |
| - | Suggested packages: | + | |
| - | git-daemon-run git-daemon-sysvinit git-doc git-el git-email git-gui gitk | + | |
| - | gitweb git-arch git-cvs git-mediawiki git-svn plymouth-themes | + | |
| - | The following NEW packages will be installed: | + | |
| - | aufs-tools cgroupfs-mount docker-ce git git-man libapparmor1 liberror-perl | + | |
| - | libnih-dbus1 libnih1 makedev mountall plymouth rsync | + | |
| - | 0 upgraded, 13 newly installed, 0 to remove and 99 not upgraded. | + | |
| - | Need to get 26.5 MB of archives. | + | |
| - | After this operation, 123 MB of additional disk space will be used. | + | |
| - | Do you want to continue? [Y/n] | + | |
| - | </ | + | |
| - | + | ||
| - | Dernièrement, | + | |
| < | < | ||
| - | root@debian9: | + | root@debian9: |
| - | Client: Docker Engine - Community | + | 0 |
| - | | + | |
| - | API version: | + | |
| - | Go version: | + | |
| - | Git commit: | + | |
| - | | + | |
| - | OS/Arch: linux/amd64 | + | |
| - | | + | |
| - | + | ||
| - | Server: Docker Engine - Community | + | |
| - | | + | |
| - | Version: | + | |
| - | API version: | + | |
| - | Go version: | + | |
| - | Git commit: | + | |
| - | Built: | + | |
| - | OS/Arch: linux/amd64 | + | |
| - | | + | |
| - | | + | |
| - | Version: | + | |
| - | GitCommit: | + | |
| - | | + | |
| - | Version: | + | |
| - | GitCommit: | + | |
| - | | + | |
| - | Version: | + | |
| - | GitCommit: | + | |
| </ | </ | ||
| - | <WRAP center round important> | + | Fixez donc la valeur à **1** et appliquez |
| - | **Important** - Docker est composé de trois éléments : un serveur, un client | + | |
| - | </ | + | |
| - | + | ||
| - | Re-démarrez | + | |
| < | < | ||
| - | root@debian9: | + | root@debian9: |
| + | root@debian9: | ||
| + | kernel.unprivileged_userns_clone=1 | ||
| + | root@debian9: | ||
| + | * Applying / | ||
| + | kernel.unprivileged_userns_clone = 1 | ||
| + | * Applying / | ||
| + | * Applying / | ||
| </ | </ | ||
| - | ====1.2 | + | Connectez-vous ensuite en tant que l'utilisateur **lxcnp** |
| - | + | ||
| - | Démarrez un conteneur de l'image hello-world | + | |
| < | < | ||
| - | root@debian9: | + | root@debian9: |
| - | Unable to find image ' | + | lxcnp@debian9:~$ |
| - | latest: Pulling from library/ | + | |
| - | 1b930d010525: | + | |
| - | Digest: sha256: | + | |
| - | Status: Downloaded newer image for hello-world: | + | |
| - | + | ||
| - | Hello from Docker! | + | |
| - | This message shows that your installation appears to be working correctly. | + | |
| - | + | ||
| - | To generate this message, Docker took the following steps: | + | |
| - | 1. The Docker client contacted the Docker daemon. | + | |
| - | 2. The Docker daemon pulled the " | + | |
| - | (amd64) | + | |
| - | 3. The Docker daemon created a new container from that image which runs the | + | |
| - | executable that produces the output you are currently reading. | + | |
| - | 4. The Docker daemon streamed that output to the Docker client, which sent it | + | |
| - | to your terminal. | + | |
| - | + | ||
| - | To try something more ambitious, you can run an Ubuntu container with: | + | |
| - | $ docker run -it ubuntu bash | + | |
| - | + | ||
| - | Share images, automate workflows, and more with a free Docker ID: | + | |
| - | | + | |
| - | + | ||
| - | For more examples and ideas, visit: | + | |
| - | | + | |
| </ | </ | ||
| - | <WRAP center round important> | + | Créez |
| - | **Important** - Notez que si l' | + | |
| - | </WRAP> | + | |
| - | + | ||
| - | Démarrez un conteneur de l' | + | |
| < | < | ||
| - | root@debian9:~# docker run -it ubuntu bash | + | lxcnp@debian9:~$ mkdir -p ~/.config/lxc |
| - | Unable to find image ' | + | |
| - | latest: Pulling from library/ubuntu | + | |
| - | 898c46f3b1a1: | + | |
| - | 63366dfa0a50: | + | |
| - | 041d4cd74a92: | + | |
| - | 6e1bee0f8701: | + | |
| - | Digest: sha256: | + | |
| - | Status: Downloaded newer image for ubuntu: | + | |
| - | root@3a3f9bda6cbd: | + | |
| - | bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var | + | |
| - | root@3a3f9bda6cbd:/# | + | |
| - | DISTRIB_ID=Ubuntu | + | |
| - | DISTRIB_RELEASE=18.04 | + | |
| - | DISTRIB_CODENAME=bionic | + | |
| - | DISTRIB_DESCRIPTION=" | + | |
| </ | </ | ||
| - | <WRAP center round important> | + | Créez trois entrées |
| - | **Important** - Notez que dans ce cas le conteneur est lancé avec comme argument | + | |
| - | </WRAP> | + | |
| - | + | ||
| - | Consulter la liste des paquets installés dans le conteneur ubuntu | + | |
| < | < | ||
| - | root@835001339e79:/# dpkg -l | + | lxcnp@debian9:~$ echo "lxc.include = /etc/lxc/default.conf" >> |
| - | Desired=Unknown/ | + | |
| - | | Status=Not/ | + | |
| - | |/ Err? | + | |
| - | ||/ Name | + | |
| - | +++-====================================-=======================-=======================-============================================================================= | + | |
| - | ii adduser | + | |
| - | ii apt 1.6.8 | + | |
| - | ii base-files | + | |
| - | ii base-passwd | + | |
| - | ii bash | + | |
| - | ii bsdutils | + | |
| - | ii bzip2 1.0.6-8.1 | + | |
| - | ii coreutils | + | |
| - | ii dash | + | |
| - | ii debconf | + | |
| - | ii debianutils | + | |
| - | ii diffutils | + | |
| - | ii dpkg | + | |
| - | ii e2fsprogs | + | |
| - | ii fdisk 2.31.1-0.4ubuntu3.3 | + | |
| - | ii findutils | + | |
| - | ii gcc-8-base: | + | |
| - | ii gpgv | + | |
| - | ii grep | + | |
| - | ii gzip | + | |
| - | ii hostname | + | |
| - | ii init-system-helpers | + | |
| - | ii libacl1: | + | |
| - | ii libapt-pkg5.0: | + | |
| - | ii libattr1: | + | |
| - | ii libaudit-common | + | |
| - | ii libaudit1: | + | |
| - | ii libblkid1: | + | |
| - | ii libbz2-1.0: | + | |
| - | ii libc-bin | + | |
| - | ii libc6: | + | |
| - | ii libcap-ng0: | + | |
| - | ii libcom-err2: | + | |
| - | ii libdb5.3: | + | |
| - | ii libdebconfclient0: | + | |
| - | ii libext2fs2: | + | |
| - | ii libfdisk1: | + | |
| - | ii libffi6: | + | |
| - | ii libgcc1: | + | |
| - | ii libgcrypt20: | + | |
| - | ii libgmp10: | + | |
| - | ii libgnutls30: | + | |
| - | ii libgpg-error0: | + | |
| - | ii libhogweed4: | + | |
| - | ii libidn2-0: | + | |
| - | ii liblz4-1: | + | |
| - | ii liblzma5: | + | |
| - | ii libmount1: | + | |
| - | ii libncurses5: | + | |
| - | ii libncursesw5: | + | |
| - | ii libnettle6: | + | |
| - | ii libp11-kit0: | + | |
| - | ii libpam-modules: | + | |
| - | ii libpam-modules-bin | + | |
| - | ii libpam-runtime | + | |
| - | ii libpam0g: | + | |
| - | ii libpcre3: | + | |
| - | ii libprocps6: | + | |
| - | ii libseccomp2: | + | |
| - | ii libselinux1: | + | |
| - | ii libsemanage-common | + | |
| - | ii libsemanage1: | + | |
| - | ii libsepol1: | + | |
| - | ii libsmartcols1: | + | |
| - | ii libss2: | + | |
| - | ii libstdc++6: | + | |
| - | ii libsystemd0: | + | |
| - | ii libtasn1-6: | + | |
| - | ii libtinfo5: | + | |
| - | ii libudev1: | + | |
| - | ii libunistring2: | + | |
| - | ii libuuid1: | + | |
| - | ii libzstd1: | + | |
| - | ii login 1: | + | |
| - | ii lsb-base | + | |
| - | ii mawk | + | |
| - | ii mount 2.31.1-0.4ubuntu3.3 | + | |
| - | ii ncurses-base | + | |
| - | ii ncurses-bin | + | |
| - | ii passwd | + | |
| - | ii perl-base | + | |
| - | ii procps | + | |
| - | ii sed 4.4-2 | + | |
| - | ii sensible-utils | + | |
| - | ii sysvinit-utils | + | |
| - | ii tar 1.29b-2ubuntu0.1 | + | |
| - | ii ubuntu-keyring | + | |
| - | ii util-linux | + | |
| - | ii zlib1g: | + | |
| - | root@835001339e79:/# | + | |
| - | exit | + | |
| - | root@debian9: | + | |
| - | </ | + | |
| - | Les options de la commande docker run peuvent être visualisées avec la commande | + | lxcnp@debian9:~$ echo " |
| - | < | + | lxcnp@debian9:~$ echo " |
| - | root@debian9:~# docker run --help | + | |
| - | Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...] | + | lxcnp@debian9:~$ cat ~/.config/lxc/default.conf |
| - | + | lxc.include = /etc/lxc/default.conf | |
| - | Run a command in a new container | + | lxc.id_map = u 0 165536 65536 |
| - | + | lxc.id_map = g 0 165536 65536 | |
| - | Options: | + | |
| - | --add-host list Add a custom host-to-IP mapping (host:ip) | + | |
| - | -a, --attach list Attach to STDIN, STDOUT or STDERR | + | |
| - | --blkio-weight uint16 | + | |
| - | --blkio-weight-device list Block IO weight (relative device weight) (default []) | + | |
| - | --cap-add list Add Linux capabilities | + | |
| - | --cap-drop list Drop Linux capabilities | + | |
| - | --cgroup-parent string | + | |
| - | --cidfile string | + | |
| - | --cpu-period int Limit CPU CFS (Completely Fair Scheduler) period | + | |
| - | --cpu-quota int Limit CPU CFS (Completely Fair Scheduler) quota | + | |
| - | --cpu-rt-period int Limit CPU real-time period in microseconds | + | |
| - | --cpu-rt-runtime int Limit CPU real-time runtime in microseconds | + | |
| - | -c, --cpu-shares int CPU shares (relative weight) | + | |
| - | --cpus decimal | + | |
| - | --cpuset-cpus string | + | |
| - | --cpuset-mems string | + | |
| - | -d, --detach | + | |
| - | --detach-keys string | + | |
| - | --device list Add a host device to the container | + | |
| - | --device-cgroup-rule list Add a rule to the cgroup allowed devices list | + | |
| - | --device-read-bps list Limit read rate (bytes per second) from a device (default []) | + | |
| - | --device-read-iops list Limit read rate (IO per second) from a device (default []) | + | |
| - | --device-write-bps list Limit write rate (bytes per second) to a device (default []) | + | |
| - | --device-write-iops list Limit write rate (IO per second) to a device (default []) | + | |
| - | --disable-content-trust | + | |
| - | --dns list Set custom DNS servers | + | |
| - | --dns-option list Set DNS options | + | |
| - | --dns-search list Set custom DNS search domains | + | |
| - | --entrypoint string | + | |
| - | -e, --env list Set environment variables | + | |
| - | --env-file list Read in a file of environment variables | + | |
| - | --expose list Expose a port or a range of ports | + | |
| - | --group-add list Add additional groups to join | + | |
| - | --health-cmd string | + | |
| - | --health-interval duration | + | |
| - | --health-retries int | + | |
| - | --health-start-period duration | + | |
| - | --health-timeout duration | + | |
| - | --help | + | |
| - | -h, --hostname string | + | |
| - | --init | + | |
| - | -i, --interactive | + | |
| - | --ip string | + | |
| - | --ip6 string | + | |
| - | --ipc string | + | |
| - | --isolation string | + | |
| - | --kernel-memory bytes Kernel memory limit | + | |
| - | -l, --label list Set meta data on a container | + | |
| - | --label-file list Read in a line delimited file of labels | + | |
| - | --link list Add link to another container | + | |
| - | --link-local-ip list | + | |
| - | --log-driver string | + | |
| - | --log-opt list Log driver options | + | |
| - | --mac-address string | + | |
| - | -m, --memory bytes | + | |
| - | --memory-reservation bytes | + | |
| - | --memory-swap bytes Swap limit equal to memory plus swap: ' | + | |
| - | --memory-swappiness int Tune container memory swappiness (0 to 100) (default -1) | + | |
| - | --mount mount Attach a filesystem mount to the container | + | |
| - | --name string | + | |
| - | --network string | + | |
| - | --network-alias list Add network-scoped alias for the container | + | |
| - | --no-healthcheck | + | |
| - | --oom-kill-disable | + | |
| - | --oom-score-adj int Tune host's OOM preferences (-1000 to 1000) | + | |
| - | --pid string | + | |
| - | --pids-limit int Tune container pids limit (set -1 for unlimited) | + | |
| - | --privileged | + | |
| - | -p, --publish list | + | |
| - | -P, --publish-all | + | |
| - | --read-only | + | |
| - | --restart string | + | |
| - | --rm | + | |
| - | --runtime string | + | |
| - | --security-opt list Security Options | + | |
| - | --shm-size bytes Size of /dev/shm | + | |
| - | --sig-proxy | + | |
| - | | + | |
| - | --stop-timeout int | + | |
| - | --storage-opt list | + | |
| - | --sysctl map | + | |
| - | --tmpfs list Mount a tmpfs directory | + | |
| - | -t, --tty Allocate a pseudo-TTY | + | |
| - | --ulimit ulimit | + | |
| - | -u, --user string | + | |
| - | | + | |
| - | --uts string | + | |
| - | -v, --volume list Bind mount a volume | + | |
| - | --volume-driver string | + | |
| - | --volumes-from list Mount volumes from the specified container(s) | + | |
| - | -w, --workdir string | + | |
| </ | </ | ||
| - | ====1.3 | + | Déconnectez-vous et reconnectez-vous en tant que l'utilisateur |
| - | + | ||
| - | Pour consulter tous les conteneurs, utilisez la commande **docker ps** avec l'option | + | |
| < | < | ||
| - | root@debian9: | + | lxcnp@debian9: |
| - | CONTAINER ID IMAGE | + | déconnexion |
| - | 3a3f9bda6cbd | + | root@debian9: |
| - | 26ef17bd115d | + | lxcnp@debian9: |
| </ | </ | ||
| - | <WRAP center round important> | + | ==Création du Conteneur== |
| - | **Important** - Notez que chaque conteneur peut être référencé par son **CONTAINER ID** ou par son **NAME**. | + | |
| - | </ | + | |
| - | Pour consulter la liste des images, utilisez la commande | + | Créez maintenant un conteneur non-privilégié appelé |
| < | < | ||
| - | root@debian9:~# docker images | + | lxcnp@debian9:~$ lxc-create -n lxc-bb-np -t busybox |
| - | REPOSITORY | + | WARN: could not reopen tty: Permission denied |
| - | ubuntu | + | WARN: could not reopen tty: Permission denied |
| - | hello-world | + | WARN: could not reopen tty: Permission denied |
| - | </code> | + | WARN: could not reopen tty: Permission denied |
| + | WARN: could not reopen tty: Permission denied | ||
| + | WARN: could not reopen tty: Permission denied | ||
| + | WARN: could not reopen tty: Permission denied | ||
| + | WARN: could not reopen tty: Permission denied | ||
| + | WARN: could not reopen tty: Permission denied | ||
| + | WARN: could not reopen tty: Permission denied | ||
| + | WARN: could not reopen tty: Permission denied | ||
| + | WARN: could not reopen tty: Permission denied | ||
| + | chmod: impossible d' | ||
| + | setting root password to " | ||
| + | Failed to change root password | ||
| - | <WRAP center round important> | + | lxcnp@debian9:~$ ls -l /home/lxcnp/.local/share/lxc/lxc-bb-np/rootfs/ |
| - | **Important** - Notez que chaque image est référencée par son IMAGE ID. | + | total 60 |
| - | </ | + | drwxr-xr-x 2 165536 165536 4096 juil. 29 13:11 bin |
| - | + | drwxr-xr-x 4 165536 165536 4096 juil. 29 13:11 dev | |
| - | ====1.4 - Rechercher une Image dans un Dépôt==== | + | drwxr-xr-x 3 165536 165536 4096 juil. 29 13:11 etc |
| - | + | drwxr-xr-x 2 165536 165536 4096 juil. 29 13:11 home | |
| - | Pour rechercher une image docker dans le dépôt par défaut, utilisez la commande **docker search** : | + | drwxr-xr-x 2 165536 165536 4096 juil. 29 13:11 lib |
| - | + | drwxr-xr-x 2 165536 165536 4096 juil. 29 13:11 lib64 | |
| - | < | + | drwxr-xr-x 2 165536 165536 4096 juil. 29 13:11 mnt |
| - | root@debian9:~# docker search | + | drwxr-xr-x 2 165536 165536 4096 juil. 29 13:11 proc |
| - | Flag --stars has been deprecated, use --filter=stars=3 instead | + | drwxr-xr-x 2 165536 165536 4096 juil. 29 13:11 root |
| - | NAME DESCRIPTION | + | drwxr-xr-x 2 165536 165536 4096 juil. 29 13:11 sbin |
| - | centos | + | drwxr-xr-x 2 165536 165536 4096 juil. 29 13:11 selinux |
| - | ansible/centos7-ansible | + | drwxr-xr-x 2 165536 165536 4096 juil. 29 13:11 sys |
| - | jdeathe/centos-ssh | + | drwxr-xr-x 2 165536 165536 4096 juil. 29 13:11 tmp |
| - | consol/centos-xfce-vnc | + | drwxr-xr-x 7 165536 165536 4096 juil. 29 13:11 usr |
| - | imagine10255/centos6-lnmp-php56 | + | drwxr-xr-x 3 165536 165536 4096 juil. 29 13:11 var |
| - | centos/mysql-57-centos7 | + | |
| - | tutum/centos | + | |
| - | gluster/gluster-centos | + | |
| - | openshift/ | + | |
| - | centos/ | + | |
| - | centos/ | + | |
| - | kinogmt/ | + | |
| - | centos/php-56-centos7 | + | |
| - | openshift/ | + | |
| - | pivotaldata/ | + | |
| - | openshift/ | + | |
| - | root@debian9:~# | + | |
| - | root@debian9: | + | |
| - | NAME DESCRIPTION | + | |
| - | centos | + | |
| - | ansible/ | + | |
| - | jdeathe/ | + | |
| - | consol/ | + | |
| - | imagine10255/ | + | |
| - | centos/ | + | |
| - | tutum/ | + | |
| - | gluster/ | + | |
| - | openshift/ | + | |
| - | centos/ | + | |
| - | centos/ | + | |
| - | kinogmt/ | + | |
| - | centos/ | + | |
| - | centos/php-56-centos7 | + | |
| - | openshift/ | + | |
| - | pivotaldata/ | + | |
| - | openshift/ | + | |
| </ | </ | ||
| - | <WRAP center round important> | + | ==Contrôle du Mappage== |
| - | **Important** - Notez que chaque image est référencée par la colonne NAME. Le NAME est sous le format **repository/ | + | |
| - | </ | + | |
| - | + | ||
| - | ====1.5 - Supprimer un Conteneur d'une Image==== | + | |
| - | Pour supprimer un conteneur d'une image, il convient d' | + | Démarrez |
| < | < | ||
| - | root@debian9:~# docker ps -a | + | lxcnp@debian9:~$ lxc-start -n lxc-bb-np |
| - | CONTAINER ID IMAGE | + | lxcnp@debian9:~$ lxc-ls -f --running |
| - | 3a3f9bda6cbd | + | NAME STATE |
| - | 26ef17bd115d | + | lxc-bb-np RUNNING |
| - | root@debian9:~# docker rm wizardly_buck | + | |
| - | wizardly_buck | + | |
| - | root@debian9: | + | |
| - | CONTAINER ID IMAGE | + | |
| - | 26ef17bd115d | + | |
| - | root@debian9: | + | |
| - | REPOSITORY | + | |
| - | ubuntu | + | |
| - | hello-world | + | |
| </ | </ | ||
| - | <WRAP center round important> | + | Attachez-vous au conteneur et contrôlez |
| - | **Important** | + | |
| - | </ | + | |
| - | + | ||
| - | ====1.6 -Créer une Image à partir d'un Conteneur Modifié==== | + | |
| - | + | ||
| - | Modifier un conteneur d'une image : | + | |
| < | < | ||
| - | root@debian9:~# docker run -it ubuntu | + | lxcnp@debian9:~$ lxc-attach -n lxc-bb-np |
| - | root@54b0dae2f3a9:/# ls | + | WARN: could not reopen tty: Permission denied |
| - | bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var | + | WARN: could not reopen tty: Permission denied |
| - | root@54b0dae2f3a9:/# rm -rf /home | + | WARN: could not reopen tty: Permission denied |
| - | root@54b0dae2f3a9:/# ls | + | |
| - | bin boot dev etc lib lib64 media mnt opt proc root run sbin srv sys tmp usr var | + | |
| - | root@54b0dae2f3a9:/# exit | + | |
| - | exit | + | |
| - | root@debian9:~# | + | |
| - | </ | + | |
| - | <WRAP center round important> | ||
| - | **Important** - Notez ici la suppression du répertoire **home** dans le conteneur **54b0dae2f3a9**. | ||
| - | </ | ||
| - | Consultez la différence entre le conteneur et l' | + | BusyBox v1.22.1 (Debian 1:1.22.0-19+b3) built-in shell (ash) |
| + | Enter ' | ||
| - | < | + | / # ps aux |
| - | root@debian9: | + | PID |
| - | CONTAINER ID IMAGE COMMAND | + | 1 root |
| - | 54b0dae2f3a9 | + | 4 root /bin/syslogd |
| - | 26ef17bd115d | + | 7 root /bin/getty -L tty1 115200 vt100 |
| - | root@debian9:~# docker diff tender_mendeleev | + | |
| - | C /root | + | |
| - | A /root/.bash_history | + | 10 root ps aux |
| - | D /home | + | / # |
| </ | </ | ||
| - | <WRAP center round important> | + | Détachez-vous du conteneur et sortez du compte |
| - | **Important** | + | |
| - | </ | + | |
| - | + | ||
| - | Créez un autre conteneur à partir de l' | + | |
| < | < | ||
| - | root@debian9: | + | / # exit |
| - | root@92f0d4bb7967: | + | lxcnp@debian9:~$ exit |
| - | bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var | + | déconnexion |
| - | root@92f0d4bb7967:/# exit | + | |
| - | exit | + | |
| root@debian9: | root@debian9: | ||
| </ | </ | ||
| - | <WRAP center round important> | + | Dernièrement, vérifiez l'UID de l'utilisateur des processus appartenant au conteneur : |
| - | **Important** - Dans ce nouveau conteneur, le répertoire **/home** est présent compte tenu du fait qu'il a été généré à partir | + | |
| - | </ | + | |
| - | + | ||
| - | Créez maintenant l' | + | |
| < | < | ||
| - | root@debian9: | + | root@debian9: |
| - | CONTAINER ID IMAGE | + | 165536 |
| - | 92f0d4bb7967 | + | 165536 |
| - | 54b0dae2f3a9 | + | 165536 |
| - | 26ef17bd115d | + | 165536 |
| - | root@debian9:~# docker commit tender_mendeleev ubuntu_1 | + | root |
| - | sha256: | + | |
| - | root@debian9:~# docker images | + | |
| - | REPOSITORY | + | |
| - | ubuntu_1 | + | |
| - | ubuntu | + | |
| - | hello-world | + | |
| </ | </ | ||
| - | ====1.7 - Supprimer une Image==== | + | ===2.7 - Création d'un Conteneur Éphémère=== |
| - | Créez maintenant | + | Par défaut les conteneurs LXC sont permanents. Il est possible de créer |
| - | < | + | ==La Commande lxc-copy== |
| - | root@debian9: | + | |
| - | root@904215fb79b4:/# | + | |
| - | bin boot dev etc lib lib64 media mnt opt proc root run sbin srv sys tmp usr var | + | |
| - | root@904215fb79b4:/# | + | |
| - | exit | + | |
| - | root@debian9: | + | |
| - | </ | + | |
| - | + | ||
| - | <WRAP center round important> | + | |
| - | **Important** - Notez l' | + | |
| - | </ | + | |
| - | Essayez | + | Notez que le conteneur d' |
| < | < | ||
| - | root@debian9: | + | root@debian9: |
| - | Error response from daemon: conflict: unable to remove repository reference " | + | NAME |
| - | root@debian9: | + | lxc-bb RUNNING |
| - | CONTAINER ID IMAGE | + | |
| - | 904215fb79b4 | + | |
| - | 92f0d4bb7967 | + | |
| - | 54b0dae2f3a9 | + | |
| - | 26ef17bd115d | + | |
| - | </ | + | |
| - | <WRAP center round important> | + | root@debian9: |
| - | **Important** - Notez qu'il n'est pas possible de supprimer l' | + | lxc-copy: lxccontainer.c: do_lxcapi_clone: 3079 error: Original container (lxc-bb) is running |
| - | </ | + | |
| - | + | ||
| - | Supprimez donc le conteneur **priceless_swirles** ainsi que l' | + | |
| - | + | ||
| - | < | + | |
| - | root@debian9: | + | |
| - | priceless_swirles | + | |
| - | root@debian9: | + | |
| - | CONTAINER ID IMAGE | + | |
| - | 92f0d4bb7967 | + | |
| - | 54b0dae2f3a9 | + | |
| - | 26ef17bd115d | + | |
| - | root@debian9:~# docker rmi ubuntu_1 | + | |
| - | Untagged: ubuntu_1:latest | + | |
| - | Deleted: sha256: | + | |
| - | Deleted: sha256: | + | |
| - | root@debian9: | + | |
| - | REPOSITORY | + | |
| - | ubuntu | + | |
| - | hello-world | + | |
| </ | </ | ||
| - | Pour pouvoir supprimer tous les conteneurs, listez-les par leur **Container ID** : | + | Arrêtez donc le conteneur |
| < | < | ||
| - | root@debian9: | + | root@debian9: |
| - | 92f0d4bb7967 | + | root@debian9: |
| - | 54b0dae2f3a9 | + | root@debian9: |
| - | 26ef17bd115d | + | Created lxc-bb-eph as clone of lxc-bb |
| </ | </ | ||
| - | Supprimer toutes les conteneurs | + | Attachez-vous au conteneur **lxc-bb-eph** |
| < | < | ||
| - | root@debian9: | + | root@debian9: |
| - | 92f0d4bb7967 | + | lxc-attach: missing container name, use --name option |
| - | 54b0dae2f3a9 | + | root@debian9: |
| - | 26ef17bd115d | + | |
| - | root@debian9:~# docker ps -aq | + | |
| - | root@debian9: | + | |
| - | </ | + | |
| - | Pour supprimer un conteneur dès la fin de son exécution, utilisez l' | ||
| - | < | + | BusyBox v1.22.1 (Debian 1:1.22.0-19+b3) built-in shell (ash) |
| - | root@debian9:~# docker run -it --rm ubuntu | + | Enter ' |
| - | root@d123b0112fc2:/# | + | |
| - | bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var | + | |
| - | root@d123b0112fc2:/# | + | |
| - | exit | + | |
| - | root@debian9: | + | |
| - | root@debian9: | + | |
| - | </ | + | |
| - | ====1.8 - Créer un Conteneur avec un Nom Spécific==== | + | ~ # |
| - | + | ||
| - | Créez maintenant un conteneur avec un nom spécific : | + | |
| - | + | ||
| - | < | + | |
| - | root@debian9: | + | |
| - | root@04b5ab87539a:/# | + | |
| - | bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var | + | |
| - | root@04b5ab87539a:/# | + | |
| - | exit | + | |
| - | root@debian9: | + | |
| - | CONTAINER ID IMAGE | + | |
| - | 04b5ab87539a | + | |
| </ | </ | ||
| - | Pour obtenir de l' | + | Créez |
| < | < | ||
| - | root@debian9: | + | ~ # ls -l |
| - | [ | + | total 4 |
| - | { | + | -rw-r--r-- 1 root |
| - | " | + | ~ # pwd |
| - | " | + | /root |
| - | " | + | ~ # echo "test" |
| - | " | + | ~ # ls -l |
| - | " | + | total 8 |
| - | " | + | -rw-r--r-- 1 root |
| - | " | + | -rw-r--r-- |
| - | " | + | ~ # |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | "LogPath": "/ | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | 0, | + | |
| - | 0 | + | |
| - | ], | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | ], | + | |
| - | " | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | "/ | + | |
| - | ] | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | ], | + | |
| - | " | + | |
| - | "/ | + | |
| - | ], | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | } | + | |
| - | } | + | |
| - | } | + | |
| - | } | + | |
| - | ] | + | |
| </ | </ | ||
| - | ====1.9 | + | Déconnectez-vous du conteneur |
| - | + | ||
| - | Pour exécuter une commande spécifique dans un conteneur, passez la commande en argument | + | |
| < | < | ||
| - | root@debian9: | + | ~ # exit |
| - | PATH=/ | + | |
| - | HOSTNAME=77bb110031aa | + | |
| - | HOME=/ | + | |
| - | root@debian9: | + | |
| - | </ | + | |
| - | ====1.10 | + | root@debian9: |
| - | Pour injecter une ou des variables d' | ||
| - | < | + | BusyBox v1.22.1 (Debian 1:1.22.0-19+b3) built-in shell (ash) |
| - | root@debian9:~# vi env.list | + | Enter ' |
| - | root@debian9: | + | |
| - | EDITOR=vim | + | |
| - | HOSTNAME=ubuntudocker | + | |
| - | </ | + | |
| - | < | + | ~ # ls -l |
| - | root@debian9: | + | total 8 |
| - | PATH=/ | + | -rw-r--r-- 1 root |
| - | HOSTNAME=ubuntudocker | + | -rw-r--r-- |
| - | EDITOR=vim | + | ~ # |
| - | HOME=/root | + | |
| - | root@debian9:~# | + | |
| </ | </ | ||
| - | ====1.11 | + | <WRAP center round important> |
| + | **Important** | ||
| + | </ | ||
| - | Pour modifier | + | Déconnectez-vous de nouveau et arrêtez |
| < | < | ||
| - | root@debian9: | + | ~ # exit |
| - | root@ubuntudocker:/# | + | |
| - | ubuntudocker | + | |
| - | root@ubuntudocker:/ | + | |
| - | exit | + | |
| - | root@debian9: | + | |
| - | </ | + | |
| - | ====1.12 | + | root@debian9: |
| - | Démarrer un conteneur de nginx sur le port localhost 81 : | + | root@debian9:~# lxc-ls |
| + | lxc-bb | ||
| - | < | + | root@debian9: |
| - | root@debian9: | + | lxc-start: log.c: log_open: 300 failed to open log file "/var/lib/lxc/lxc-bb-eph/lxc-bb-eph.log" : No such file or directory |
| - | Unable to find image ' | + | lxc-start: |
| - | latest: Pulling from library/ | + | |
| - | 27833a3ba0a5: | + | |
| - | e83729dd399a: | + | |
| - | ebc6a67df66d: | + | |
| - | Digest: sha256: | + | |
| - | Status: Downloaded newer image for nginx: | + | |
| - | ^Croot@debian9: | + | |
| - | </ | + | |
| - | + | ||
| - | Notez que c'est bloquant. Le fait d' | + | |
| - | + | ||
| - | < | + | |
| - | ^Croot@debian9: | + | |
| - | CONTAINER ID IMAGE | + | |
| - | 4f157e179134 | + | |
| - | 04b5ab87539a | + | |
| - | </ | + | |
| - | + | ||
| - | ====1.13 | + | |
| - | + | ||
| - | Démarrez maintenant le conteneur de nginx en mode détaché grâce à l' | + | |
| - | + | ||
| - | < | + | |
| - | root@debian9:~# docker run -d -p 81:80 nginx | + | |
| - | aabb064d4b0ade1f19216b6174631fa32a2053f6aa9d59bd724ea90ce534b004 | + | |
| - | root@debian9: | + | |
| - | CONTAINER ID IMAGE | + | |
| - | aabb064d4b0a | + | |
| - | 4f157e179134 | + | |
| - | 04b5ab87539a | + | |
| - | </code> | + | |
| - | + | ||
| - | ====1.14 | + | |
| - | + | ||
| - | Installez le navigateur texte **lynx** : | + | |
| - | + | ||
| - | < | + | |
| - | root@debian9: | + | |
| - | Lecture des listes de paquets... Fait | + | |
| - | Construction de l' | + | |
| - | Lecture des informations d' | + | |
| - | The following additional packages will be installed: | + | |
| - | lynx-common | + | |
| - | Les NOUVEAUX paquets suivants seront installés : | + | |
| - | lynx lynx-common | + | |
| - | 0 mis à jour, 2 nouvellement installés, 0 à enlever et 94 non mis à jour. | + | |
| - | Il est nécessaire de prendre 1 730 ko dans les archives. | + | |
| - | Après cette opération, 5 590 ko d' | + | |
| - | Souhaitez-vous continuer ? [O/n] o | + | |
| - | Réception de:1 http:// | + | |
| - | Réception de:2 http://ftp.fr.debian.org/ | + | |
| - | 1 730 ko réceptionnés en 6s (283 ko/s) | + | |
| - | Sélection du paquet lynx-common précédemment désélectionné. | + | |
| - | (Lecture de la base de données... 113082 fichiers et répertoires déjà installés.) | + | |
| - | Préparation du dépaquetage de .../ | + | |
| - | Dépaquetage de lynx-common (2.8.9dev11-1) ... | + | |
| - | Sélection du paquet lynx précédemment désélectionné. | + | |
| - | Préparation du dépaquetage de .../ | + | |
| - | Dépaquetage de lynx (2.8.9dev11-1) ... | + | |
| - | Traitement des actions différées (« triggers ») pour mime-support (3.60) ... | + | |
| - | Traitement des actions différées (« triggers ») pour man-db (2.7.6.1-2) ... | + | |
| - | Paramétrage de lynx-common (2.8.9dev11-1) ... | + | |
| - | Paramétrage de lynx (2.8.9dev11-1) ... | + | |
| - | update-alternatives: | + | |
| - | </ | + | |
| - | + | ||
| - | Vérifiez que nginx répond aux requetes : | + | |
| - | + | ||
| - | < | + | |
| - | root@debian9: | + | |
| - | | + | |
| - | + | ||
| - | If you see this page, the nginx web server is successfully installed | + | |
| - | and working. Further configuration is required. | + | |
| - | + | ||
| - | For online documentation and support please refer to [1]nginx.org. | + | |
| - | | + | |
| - | + | ||
| - | Thank you for using nginx. | + | |
| - | + | ||
| - | Références | + | |
| - | + | ||
| - | 1. http:// | + | |
| - | 2. http:// | + | |
| - | </ | + | |
| - | + | ||
| - | ====1.15 - Arrêter et Démarrer un Conteneur==== | + | |
| - | + | ||
| - | Arrêtez le conteneur nginx : | + | |
| - | + | ||
| - | < | + | |
| - | root@debian9: | + | |
| - | CONTAINER ID IMAGE | + | |
| - | aabb064d4b0a | + | |
| - | 4f157e179134 | + | |
| - | 04b5ab87539a | + | |
| - | root@debian9: | + | |
| - | aabb | + | |
| - | root@debian9: | + | |
| - | CONTAINER ID IMAGE | + | |
| - | aabb064d4b0a | + | |
| - | 4f157e179134 | + | |
| - | 04b5ab87539a | + | |
| - | </ | + | |
| - | + | ||
| - | Démarrez de nouveau le conteneur de nginx : | + | |
| - | + | ||
| - | < | + | |
| - | root@debian9: | + | |
| - | aabb | + | |
| - | root@debian9:~# docker ps -a | + | |
| - | CONTAINER ID IMAGE | + | |
| - | aabb064d4b0a | + | |
| - | 4f157e179134 | + | |
| - | 04b5ab87539a | + | |
| - | </ | + | |
| - | + | ||
| - | ====1.16 - Utiliser des Signaux avec un Conteneur==== | + | |
| - | + | ||
| - | Utilisez un signal pour tuer le processus du conteneur de nginx : | + | |
| - | + | ||
| - | < | + | |
| - | root@debian9:~# docker kill -s 9 aabb | + | |
| - | aabb | + | |
| - | root@debian9: | + | |
| - | CONTAINER ID IMAGE | + | |
| - | aabb064d4b0a | + | |
| - | 4f157e179134 | + | |
| - | 04b5ab87539a | + | |
| - | </ | + | |
| - | + | ||
| - | Redémarrez un conteneur en cours : | + | |
| - | + | ||
| - | < | + | |
| - | root@debian9: | + | |
| - | aabb | + | |
| - | root@debian9: | + | |
| - | CONTAINER ID IMAGE | + | |
| - | aabb064d4b0a | + | |
| - | 4f157e179134 | + | |
| - | 04b5ab87539a | + | |
| - | root@debian9: | + | |
| - | aabb | + | |
| - | root@debian9: | + | |
| - | CONTAINER ID IMAGE | + | |
| - | aabb064d4b0a | + | |
| - | 4f157e179134 | + | |
| - | 04b5ab87539a | + | |
| - | </ | + | |
| - | + | ||
| - | ====1.17 - Forcer la Suppression d'un Conteneur en cours d' | + | |
| - | + | ||
| - | Supprimez un conteneur en cours d' | + | |
| - | + | ||
| - | < | + | |
| - | root@debian9: | + | |
| - | Error response from daemon: You cannot remove a running container aabb064d4b0ade1f19216b6174631fa32a2053f6aa9d59bd724ea90ce534b004. Stop the container before attempting removal or force remove | + | |
| - | root@debian9: | + | |
| - | CONTAINER ID IMAGE | + | |
| - | aabb064d4b0a | + | |
| - | 4f157e179134 | + | |
| - | 04b5ab87539a | + | |
| - | root@debian9: | + | |
| - | aabb | + | |
| - | root@debian9: | + | |
| - | CONTAINER ID IMAGE | + | |
| - | 4f157e179134 | + | |
| - | 04b5ab87539a | + | |
| - | </ | + | |
| - | + | ||
| - | ====1.18 - Utilisation Simple d'un Volume==== | + | |
| - | + | ||
| - | Créez le fichier index.html et placez-le dans le répertoire /root/www : | + | |
| - | + | ||
| - | < | + | |
| - | root@debian9: | + | |
| - | root@debian9: | + | |
| - | root@debian9: | + | |
| - | < | + | |
| - | < | + | |
| - | < | + | |
| - | </ | + | |
| - | </ | + | |
| - | root@debian9: | + | |
| - | </ | + | |
| - | + | ||
| - | Indiquez au conteneur que son répertoire **/ | + | |
| - | + | ||
| - | < | + | |
| - | root@debian9: | + | |
| - | c080793965de8a6a60db212d7e4d96de84b55352c224c054dced75b409e39bf2 | + | |
| - | root@debian9: | + | |
| - | Accueil du site nginx | + | |
| - | + | ||
| - | + | ||
| - | root@debian9: | + | |
| </ | </ | ||
| <WRAP center round important> | <WRAP center round important> | ||
| - | **Important** - Notez ici l' | + | **Important** - Notez que le conteneur |
| </ | </ | ||
| - | ====1.19 - Télécharger une image sans créer un conteneur==== | + | ===2.8 - Sauvegarde des Conteneurs=== |
| - | Téléchargez l' | + | Un conteneur |
| - | < | + | * utiliser la commande **tar** ou **cpio** pour créer un archive du répertoire **rootfs** et du fichier **config** associés au conteneur |
| - | root@debian9: | + | * utiliser la commande **lxc-copy** sans l' |
| - | Using default tag: latest | + | * utiliser la commande **lxc-snapshot** |
| - | latest: Pulling from library/ | + | |
| - | 8ba884070f61: | + | |
| - | Digest: sha256: | + | |
| - | Status: Downloaded newer image for centos: | + | |
| - | </ | + | |
| - | Vérifiez le contenu de l' | + | ==La Commande lxc-snapshot== |
| - | < | + | Cette commande permet de gérer des instantanées des conteneurs. A noter que les conteneurs doivent être arrêtés avant de prendre une instantanée |
| - | root@debian9: | + | |
| - | [root@86252a3f00f4 /]# cat / | + | |
| - | CentOS Linux release 7.6.1810 (Core) | + | |
| - | [root@86252a3f00f4 /]# rpm -qa | more | + | |
| - | bind-license-9.9.4-73.el7_6.noarch | + | |
| - | bash-4.2.46-31.el7.x86_64 | + | |
| - | glibc-common-2.17-260.el7_6.3.x86_64 | + | |
| - | nss-softokn-freebl-3.36.0-5.el7_5.x86_64 | + | |
| - | filesystem-3.2-25.el7.x86_64 | + | |
| - | glibc-2.17-260.el7_6.3.x86_64 | + | |
| - | nspr-4.19.0-1.el7_5.x86_64 | + | |
| - | popt-1.13-16.el7.x86_64 | + | |
| - | libcom_err-1.42.9-13.el7.x86_64 | + | |
| - | libcap-2.22-9.el7.x86_64 | + | |
| - | libstdc++-4.8.5-36.el7.x86_64 | + | |
| - | info-5.1-5.el7.x86_64 | + | |
| - | gawk-4.0.2-4.el7_3.1.x86_64 | + | |
| - | libselinux-2.5-14.1.el7.x86_64 | + | |
| - | grep-2.20-3.el7.x86_64 | + | |
| - | keyutils-libs-1.5.8-3.el7.x86_64 | + | |
| - | libverto-0.2.5-4.el7.x86_64 | + | |
| - | p11-kit-trust-0.23.5-3.el7.x86_64 | + | |
| - | openssl-libs-1.0.2k-16.el7.x86_64 | + | |
| - | krb5-libs-1.15.1-37.el7_6.x86_64 | + | |
| - | xz-libs-5.2.2-1.el7.x86_64 | + | |
| - | libdb-5.3.21-24.el7.x86_64 | + | |
| - | libgpg-error-1.12-3.el7.x86_64 | + | |
| - | libgcrypt-1.5.3-14.el7.x86_64 | + | |
| - | lua-5.1.4-15.el7.x86_64 | + | |
| - | libuuid-2.23.2-59.el7.x86_64 | + | |
| - | libmount-2.23.2-59.el7.x86_64 | + | |
| - | shared-mime-info-1.8-4.el7.x86_64 | + | |
| - | gzip-1.5-10.el7.x86_64 | + | |
| - | findutils-4.5.11-6.el7.x86_64 | + | |
| - | diffutils-3.3-4.el7.x86_64 | + | |
| - | expat-2.1.0-10.el7_3.x86_64 | + | |
| - | audit-libs-2.8.4-4.el7.x86_64 | + | |
| - | pam-1.1.8-22.el7.x86_64 | + | |
| - | nss-softokn-3.36.0-5.el7_5.x86_64 | + | |
| - | nss-3.36.0-7.1.el7_6.x86_64 | + | |
| - | libassuan-2.1.0-3.el7.x86_64 | + | |
| - | nss-tools-3.36.0-7.1.el7_6.x86_64 | + | |
| - | gobject-introspection-1.56.1-1.el7.x86_64 | + | |
| - | --More-- | + | |
| - | </ | + | |
| - | + | ||
| - | ====1.20 - S' | + | |
| - | + | ||
| - | Arretez le conteneur. Démarrez le conteneur puis rattachez-vous au conteneur | + | |
| < | < | ||
| - | [root@86252a3f00f4 /]# exit | + | root@debian9: |
| - | exit | + | |
| - | root@debian9: | + | |
| - | CONTAINER ID IMAGE | + | |
| - | 86252a3f00f4 | + | |
| - | c080793965de | + | |
| - | 4f157e179134 | + | |
| - | 04b5ab87539a | + | |
| - | root@debian9: | + | |
| - | 8625 | + | |
| - | root@debian9: | + | |
| - | [root@86252a3f00f4 /]# ls | + | |
| - | anaconda-post.log | + | |
| - | [root@86252a3f00f4 /]# | + | |
| - | </ | + | |
| - | ====1.21 - Installer un logiciel dans le conteneur==== | + | root@debian9:~# lxc-snapshot |
| - | + | lxc-snapshot: | |
| - | Créez le fichier **/ | + | lxc-snapshot: lxccontainer.c: do_lxcapi_snapshot: |
| - | + | lxc-snapshot: lxccontainer.c: do_lxcapi_snapshot: | |
| - | < | + | lxc-snapshot: lxccontainer.c: do_lxcapi_snapshot: |
| - | [root@86252a3f00f4 /]# vi / | + | |
| - | [root@86252a3f00f4 /]# cat /etc/yum.repos.d/ | + | |
| - | [mongodb-org-4.2] | + | |
| - | name=MongoDB Repository | + | |
| - | baseurl=https:// | + | |
| - | gpgcheck=1 | + | |
| - | enabled=1 | + | |
| - | gpgkey=https://www.mongodb.org/ | + | |
| - | [root@86252a3f00f4 /]# | + | |
| </ | </ | ||
| - | Installez mongo : | + | Les snapshots sont stockés dans le sous-répertoire **snaps** du répertoire **/ |
| < | < | ||
| - | [root@86252a3f00f4 /]# yum install | + | root@debian9:~# ls -l / |
| - | </ | + | total 12 |
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | drwxr-xr-x 17 root root 4096 juil. 28 15:50 rootfs | ||
| + | drwxr-xr-x | ||
| - | Démarrez mongod : | + | root@debian9:~# ls -l / |
| - | + | total 4 | |
| - | < | + | drwxrwx--- 3 root root 4096 juil. 29 17:34 snap0 |
| - | [root@86252a3f00f4 /]# mongod | + | |
| - | [1] 82 | + | |
| - | [root@86252a3f00f4 /]# about to fork child process, waiting until server is ready for connections. | + | |
| - | forked process: 84 | + | |
| - | child process started successfully, | + | |
| - | [1]+ Done mongod | + | root@debian9: |
| - | [root@86252a3f00f4 /]# | + | total 12 |
| + | -rw-r--r-- | ||
| + | drwxr-xr-x 17 root root 4096 juil. 28 15:50 rootfs | ||
| + | -rw-r--r-- | ||
| </ | </ | ||
| - | Vérifiez que mongod | + | L' |
| < | < | ||
| - | [root@86252a3f00f4 /]# ps aux | + | root@debian9:~# cat /var/ |
| - | USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | + | 2020:07:29 17:34: |
| - | root | + | |
| - | root 84 1.2 2.2 294692 46716 ? Sl | + | |
| - | root | + | |
| </ | </ | ||
| - | Utilisez le client mongo pour se connecter au serveur | + | En comparant la taille du **rootfs** du conteneur d' |
| < | < | ||
| - | [root@86252a3f00f4 /]# mongo | + | root@debian9:~# du -sh /var/lib/ |
| - | MongoDB shell version: 4.2.2 | + | 792K /var/lib/lxc/lxc-bb/rootfs/ |
| - | connecting to: test | + | |
| - | Welcome to the MongoDB shell. | + | |
| - | For interactive help, type " | + | |
| - | For more comprehensive documentation, | + | |
| - | http://docs.mongodb.org/ | + | |
| - | Questions? Try the support group | + | |
| - | http://groups.google.com/group/mongodb-user | + | |
| - | Server has startup warnings: | + | |
| - | 2019-04-09T17: | + | |
| - | 2019-04-09T17: | + | |
| - | > | + | |
| - | </code> | + | |
| - | Sortez de mongo et du conteneur : | + | root@debian9: |
| - | + | 792K / | |
| - | < | + | |
| - | > exit | + | |
| - | bye | + | |
| - | [root@86252a3f00f4 /]# exit | + | |
| - | exit | + | |
| - | root@debian9: | + | |
| </ | </ | ||
| - | ====1.22 - Utilisation | + | Pour restaurer un conteneur identique à l' |
| - | + | ||
| - | Créer maintenant une nouvelle image à partir de votre conteneur | + | |
| < | < | ||
| - | root@debian9: | + | root@debian9: |
| - | CONTAINER ID IMAGE | + | |
| - | 86252a3f00f4 | + | |
| - | c080793965de | + | |
| - | 4f157e179134 | + | |
| - | 04b5ab87539a | + | |
| - | root@debian9: | + | |
| - | sha256: | + | |
| - | </ | + | |
| - | Supprimez le conteneur utilisé pour créer l' | + | root@debian9:~# lxc-ls |
| + | lxc-bb | ||
| - | < | + | root@debian9: |
| - | root@debian9: | + | |
| - | 8625 | + | |
| - | root@debian9: | + | |
| - | CONTAINER ID IMAGE | + | |
| - | c080793965de | + | |
| - | 4f157e179134 | + | |
| - | 04b5ab87539a | + | |
| - | </ | + | |
| - | Utilisez la nouvelle image pour lancer un conteneur nommé **mongo** | + | root@debian9:~# lxc-attach -n lxc-bb-snap0 |
| - | < | ||
| - | root@debian9: | ||
| - | [root@d20fb56a38b0 /]# ls / | ||
| - | / | ||
| - | / | ||
| - | [root@d20fb56a38b0 /]# ps aux | ||
| - | USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | ||
| - | root | ||
| - | root 15 0.0 0.1 51748 3468 pts/0 R+ | ||
| - | </ | ||
| - | Editez le fichier / | + | BusyBox v1.22.1 (Debian 1:1.22.0-19+b3) built-in shell (ash) |
| + | Enter ' | ||
| - | < | + | ~ # exit |
| - | [root@d20fb56a38b0 /]# echo "/ | + | |
| - | [root@d20fb56a38b0 /]# tail / | + | |
| - | . " | + | |
| - | fi | + | |
| - | fi | + | |
| - | done | + | |
| - | + | ||
| - | unset i | + | |
| - | unset -f pathmunge | + | |
| - | fi | + | |
| - | # vim: | + | |
| - | / | + | |
| - | </ | + | |
| - | + | ||
| - | Consultez la liste des conteneurs et relevez le CONTAINER ID du conteneur **mongo** : | + | |
| - | + | ||
| - | < | + | |
| - | [root@d20fb56a38b0 /]# exit | + | |
| - | exit | + | |
| - | root@debian9: | + | |
| - | CONTAINER ID IMAGE | + | |
| - | d20fb56a38b0 | + | |
| - | c080793965de | + | |
| - | 4f157e179134 | + | |
| - | 04b5ab87539a | + | |
| - | </ | + | |
| - | + | ||
| - | Utilisez la commande commit pour " | + | |
| - | + | ||
| - | < | + | |
| - | root@debian9: | + | |
| - | sha256: | + | |
| - | </ | + | |
| - | + | ||
| - | Démarrez de nouveau le conteneur pour vérifier que mongod fonctionne : | + | |
| - | + | ||
| - | < | + | |
| - | root@debian9: | + | |
| - | d20f | + | |
| - | root@debian9: | + | |
| - | CONTAINER ID IMAGE | + | |
| - | c080793965de | + | |
| - | 4f157e179134 | + | |
| - | 04b5ab87539a | + | |
| - | root@debian9: | + | |
| - | [root@bcec3f27ed58 /]# about to fork child process, waiting until server is ready for connections. | + | |
| - | forked process: 16 | + | |
| - | child process started successfully, | + | |
| - | + | ||
| - | [1]+ Done / | + | |
| - | [root@bcec3f27ed58 /]# ps aux | + | |
| - | USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | + | |
| - | root | + | |
| - | root 16 2.0 2.4 298788 49276 ? Sl | + | |
| - | root 39 0.0 0.1 51748 3476 pts/0 R+ | + | |
| - | [root@bcec3f27ed58 /]# | + | |
| - | </ | + | |
| - | + | ||
| - | ====1.23 - Se connecter au serveur du conteneur de l' | + | |
| - | + | ||
| - | Pour pouvoir se connecter à mongodb depuis la machine hôte, il convient d' | + | |
| - | + | ||
| - | < | + | |
| - | [root@bcec3f27ed58 /]# vi / | + | |
| - | [root@bcec3f27ed58 /]# cat / | + | |
| - | | + | |
| - | </ | + | |
| - | + | ||
| - | Sortez du conteneur, re-créez une image, supprimez le conteneur utilisé et relancez de nouveau le conteneur : | + | |
| - | + | ||
| - | < | + | |
| - | [root@bcec3f27ed58 /]# exit | + | |
| - | exit | + | |
| - | root@debian9: | + | |
| - | sha256: | + | |
| - | root@debian9: | + | |
| - | mongo | + | |
| - | root@debian9: | + | |
| - | [root@d2ddb4f8ca8a /]# about to fork child process, waiting until server is ready for connections. | + | |
| - | forked process: 16 | + | |
| - | [root@d2ddb4f8ca8a /]# child process started successfully, | + | |
| - | + | ||
| - | [1]+ Done / | + | |
| - | [root@d2ddb4f8ca8a /]# | + | |
| - | </ | + | |
| - | + | ||
| - | Dans votre machine hôte, configurez le dépôt de mongodb : | + | |
| - | + | ||
| - | < | + | |
| - | [root@f5b45072b831 /]# exit | + | |
| - | root@debian9: | + | |
| - | root@debian9: | + | |
| - | root@debian9: | + | |
| - | root@debian9: | + | |
| - | Executing: / | + | |
| - | gpg: key 68818C72E52529D4: | + | |
| - | gpg: Total number processed: 1 | + | |
| - | gpg: | + | |
| - | root@debian9: | + | |
| - | root@debian9: | + | |
| - | deb http:// | + | |
| root@debian9: | root@debian9: | ||
| - | root@debian9: | ||
| </ | </ | ||
| - | Cette fois, installez uniquement le client de mongodb : | ||
| - | < | + | ----- |
| - | root@debian9: | + | |
| - | Lecture des listes de paquets... Fait | + | |
| - | Construction de l' | + | |
| - | Lecture des informations d' | + | |
| - | Les NOUVEAUX paquets suivants seront installés : | + | |
| - | mongodb-org-shell | + | |
| - | 0 mis à jour, 1 nouvellement installés, 0 à enlever et 95 non mis à jour. | + | |
| - | Il est nécessaire de prendre 9 809 ko dans les archives. | + | |
| - | Après cette opération, 39,8 Mo d' | + | |
| - | Réception de:1 http:// | + | |
| - | 9 809 ko réceptionnés en 7s (1 245 ko/s) | + | |
| - | Sélection du paquet mongodb-org-shell précédemment désélectionné. | + | |
| - | (Lecture de la base de données... 91513 fichiers et répertoires déjà installés.) | + | |
| - | Préparation du dépaquetage de .../ | + | |
| - | Dépaquetage de mongodb-org-shell (4.0.8) ... | + | |
| - | Paramétrage de mongodb-org-shell (4.0.8) ... | + | |
| - | Traitement des actions différées (« triggers ») pour man-db (2.7.6.1-2) ... | + | |
| - | </ | + | |
| - | Notez qu'à ce stade le conteneur ne possède pas d' | + | Copyright © 2022 Hugh Norris. |
| - | + | ||
| - | < | + | |
| - | root@debian9: | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | </ | + | |
| - | + | ||
| - | Démarrez donc le conteneur et cherchez l' | + | |
| - | + | ||
| - | < | + | |
| - | root@debian9: | + | |
| - | mongo | + | |
| - | root@debian9: | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | </ | + | |
| - | + | ||
| - | Connectez-vous maintenant à votre mongodb à partir de la machine hôte : | + | |
| - | + | ||
| - | < | + | |
| - | root@debian9: | + | |
| - | MongoDB shell version v4.0.8 | + | |
| - | connecting to: mongodb:// | + | |
| - | WARNING: No implicit session: Logical Sessions are only supported on server versions 3.6 and greater. | + | |
| - | Implicit session: dummy session | + | |
| - | MongoDB server version: 4.2.2 | + | |
| - | WARNING: shell and server versions do not match | + | |
| - | Welcome to the MongoDB shell. | + | |
| - | For interactive help, type " | + | |
| - | For more comprehensive documentation, | + | |
| - | http:// | + | |
| - | Questions? Try the support group | + | |
| - | http:// | + | |
| - | Server has startup warnings: | + | |
| - | 2019-04-09T17: | + | |
| - | 2019-04-09T17: | + | |
| - | > | + | |
| - | </ | + | |
| - | + | ||
| - | ----- | + | |
| - | < | + | |
| - | <div align=" | + | |
| - | Copyright © 2020 Hugh Norris | + | |
| - | </ | + | |
| - | </ | + | |