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:docker3:drf09 [2021/11/21 11:52] – removed admin | elearning:workbooks:docker3:drf09 [2024/02/21 16:02] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ~~PDF: | ||
+ | |||
+ | Version : **2024.01** | ||
+ | |||
+ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
+ | |||
+ | ======DOF602 - Démarrer avec Docker====== | ||
+ | |||
+ | =====Contenu du Module===== | ||
+ | |||
+ | * **DOF602 - Démarrer avec Docker** | ||
+ | * Contenu du Module | ||
+ | * Présentation de Docker | ||
+ | * Virtualisation et Containérisation | ||
+ | * Le Système de Fichier AUFS | ||
+ | * OverlayFS et Overlay2 | ||
+ | * Docker Daemon et Docker Engine | ||
+ | * Docker CE et Docker EE | ||
+ | * Docker CE | ||
+ | * Docker EE | ||
+ | * Docker et Mirantis | ||
+ | * LAB #1 - Travailler avec Docker | ||
+ | * 1.1 - Installer docker sous Linux | ||
+ | * 1.1.1 - Debian 11 | ||
+ | * 1.1.2 - CentOS 8 | ||
+ | * 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' | ||
+ | * 1.11 - Modifier le Nom d' | ||
+ | * 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' | ||
+ | * 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' | ||
+ | * 1.18 - Utilisation Simple d'un Volume | ||
+ | * 1.19 - Télécharger une image sans créer un conteneur | ||
+ | * 1.20 - S' | ||
+ | * 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' | ||
+ | |||
+ | =====Présentation de Docker===== | ||
+ | |||
+ | ====Virtualisation et Containérisation==== | ||
+ | |||
+ | La virtualisation classique nécessite l' | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | Docker est une application de virtualisation légère lancé en 2013 qui utilise des **images** et des **conteneurs**. | ||
+ | |||
+ | Docker est composé de trois éléments : un serveur, un client et un ou plusieurs Repositories ou Dépôts : | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | Une **image** est un paquet exécutable contenant tout ce qu'il est nécessaire afin d' | ||
+ | |||
+ | * le code | ||
+ | * un runtime | ||
+ | * des bibliothèques, | ||
+ | * des variables d' | ||
+ | * des fichiers de configuration | ||
+ | |||
+ | 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 de la machine hôte. | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | ====Le Système de Fichier AUFS==== | ||
+ | |||
+ | Pour gérer le système de fichiers du conteneur, Docker utilisait au départ le filesystem AUFS. AUFS est un système de fichiers de la famille UnionFS. Un système de fichier de type UnionFS assemble des repertoires multiples les uns sur les autres pour ensuite les présenter sous forme d'un repertoire unique contenant les objets les plus récents grâce à un union mount. Les repertoires sous AUFS sont appelés des **branches** et se trouvent dans **/ | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | ====OverlayFS et Overlay2==== | ||
+ | |||
+ | Le système de fichiers AUFS a été ensuite remplacé dans Docker par le système de fichiers **OverlayFS**. Ce système de fichiers combine deux répertoires appelés **Layers**. Le layer inférieur porte le nom **lowerdir** tandis que le niveau au dessus est appelé le **upperdir**. La vue unifiée porte le nom **merged**. Dans le cas où les layers de conteneur et de l' | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | Le système de fichiers OverlayFS ne sait gérer que deux niveaux. Ceci implique une utilisation excessive d' | ||
+ | |||
+ | Cette limitation a donné lieu à l' | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **Important** - Notez que Docker peut aussi utiliser le système de fichiers BTRFS. | ||
+ | </ | ||
+ | |||
+ | ====Docker Daemon et Docker Engine==== | ||
+ | |||
+ | Le Docker Daemon, appelé **dockerd**, | ||
+ | |||
+ | * Le Docker Daemon est le serveur, | ||
+ | * Le Docker CLI est le client, | ||
+ | * Le REST API permet la communication entre le serveur et le client. | ||
+ | |||
+ | Le Docker Engine peut utiliser des **plugins**. Ces plugins, disponibles pour téléchargement à partir du **Docker Registry** public, appelé le **Docker Hub**, ajoutent des fonctionnalités supplémentaires au Docker Engine. Actuellement, | ||
+ | |||
+ | * Volumes (le partage et la réutilisation de volumes entre conteneurs, des sauvegardes et de la migration), | ||
+ | * Network | ||
+ | * Authorization | ||
+ | * Cloud (AWS, GCP et Azure) | ||
+ | * Jenkins | ||
+ | |||
+ | Il est aussi possible de créer son propre plugin. | ||
+ | |||
+ | ====Docker CE et Docker EE==== | ||
+ | |||
+ | ===Docker CE=== | ||
+ | |||
+ | Docker existe en deux versions **Docker CE** (Docker Community Edition) et **Docker EE** (Docker Enterprise Edition). | ||
+ | |||
+ | Docker CE est : | ||
+ | |||
+ | * un logiciel libre, | ||
+ | * gratuit. | ||
+ | |||
+ | Docker CE vient en deux sous-versions : | ||
+ | |||
+ | * **Stable** - mis à jour tous les trois mois. La stabilité est garantie, | ||
+ | * **Edge** - mis à jour tous les mois et contient des nouvelles fonctionnalités mais parfois au prix de la stabilité. | ||
+ | |||
+ | ===Docker EE=== | ||
+ | |||
+ | Docker EE est : | ||
+ | |||
+ | * plus puissant que la version Docker CE, | ||
+ | * disponible pour des processeurs différents (x86-64, ARM, IBM Z, s390x IBM Z). | ||
+ | |||
+ | Docker EE comprend : | ||
+ | |||
+ | * Docker Engine Enterprise, | ||
+ | * le Docker Engine qui bénéficie de support commercial. Il permet de créer de images et des conteneurs, | ||
+ | * Docker Universal Control Plane (UCP), | ||
+ | * est diviser en deux composants : UCP Worker et UCP Manager, | ||
+ | * permet le déploiement des applications et et conçu pour la haute disponibilité, | ||
+ | * permet de lier plusieurs noeuds de type UCP Manager en tant que cluster, | ||
+ | * Docker Trusted Registry (DTR), | ||
+ | * une solution de stockage sécurisée des images, | ||
+ | * est conçu pour une scalabilité horizontale, | ||
+ | * Docker Desktop Enterprise (DDE), | ||
+ | * une application Windows et Mac permettant la construction locale d' | ||
+ | | ||
+ | Docker EE est disponible en trois sous-versions, | ||
+ | |||
+ | * **Basic** - (support Docker officiel (J) et des conteneurs et plugins certifiés), | ||
+ | * $1 500 par noeud par an (2022), | ||
+ | * **Standard** - (Basic | ||
+ | * $3 000 par noeud par an (2022), | ||
+ | * **Advanced** - (Standard + l' | ||
+ | * $3 500 par noeud par an (2022). | ||
+ | |||
+ | Pour consulter les différences entre les deux versions, consultez le lien **[[https:// | ||
+ | |||
+ | ====Docker et Mirantis==== | ||
+ | |||
+ | Docker EE a été acquis par la société **Mirantis** en novembre 2019. | ||
+ | |||
+ | De ce fait Miratis a renommé certains composants de Docker EE : | ||
+ | |||
+ | * Docker Enterprise/ | ||
+ | * Docker Trusted Registry (DTR) --> Mirantis Secure Registry (MSR), | ||
+ | * Docker Engine Enterprise --> Mirantis container Runtime, | ||
+ | * Docker Enterprise Container Cloud --> Mirantis Container Cloud. | ||
+ | |||
+ | =====LAB #1 - Travailler avec Docker===== | ||
+ | |||
+ | Docker est disponible pour Windows(tm) et Mac en tant que binaire : | ||
+ | |||
+ | ^ Platform ^ x86_64 / amd64 ^ | ||
+ | | Docker Desktop for macOS | pkg | | ||
+ | | Docker Desktop for Windows(tm) | exe ou msi | | ||
+ | |||
+ | Docker est disponible pour Linux en tant que paquet rpm ou deb : | ||
+ | |||
+ | ^ Platform ^ x86_64 / amd64 ^ ARM ^ ARM64 / AARCH64 ^ | ||
+ | | CentOS | rpm | | rpm | | ||
+ | | Fedora | rpm | | rpm | | ||
+ | | Debian | deb | deb | deb | | ||
+ | | Ubuntu | deb | deb | deb | | ||
+ | | Raspian | | deb | deb | | ||
+ | |||
+ | Les paquets sont disponibles soit à partir du dépôt Docker soit dans le gestionnaire des paquets de l'OS. Docker peut aussi être installé en utilisant des scripts automatisés fournis par Docker. | ||
+ | |||
+ | Veuillez noter que depuis le changement de noms des paquets Docker, il convient de désinstaller toute version antérieure de Docker avant de procéder à l' | ||
+ | |||
+ | Par exemple sous Debian et Ubuntu : | ||
+ | |||
+ | < | ||
+ | # apt-get remove docker docker-engine docker.io containerd runc | ||
+ | </ | ||
+ | |||
+ | Sous CentOS et Fedora : | ||
+ | |||
+ | < | ||
+ | # yum remove docker docker-client docker-client-latest docker-latest docker-common docker-engine docker-logrotate docker-latest-logrotate | ||
+ | </ | ||
+ | |||
+ | Docker est disponible dans trois canaux : | ||
+ | |||
+ | * **Stable**, | ||
+ | * La dernière version GA ( General Availability ), | ||
+ | * **Test**, | ||
+ | * La version en pre-release, | ||
+ | * **Nightly**, | ||
+ | * Une version instable de travaux en cours. | ||
+ | |||
+ | ====1.1 - Installer docker sous Linux==== | ||
+ | |||
+ | ===1.1.1 - Debian 11=== | ||
+ | |||
+ | Docker n'est pas dans le dépôts de Debian. Afin de l' | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | ... | ||
+ | root@debian11: | ||
+ | Reading package lists... Done | ||
+ | Building dependency tree... Done | ||
+ | Reading state information... Done | ||
+ | ca-certificates is already the newest version (20210119). | ||
+ | gnupg2 is already the newest version (2.2.27-2+deb11u2). | ||
+ | The following packages were automatically installed and are no longer required: | ||
+ | libopengl0 linux-headers-5.10.0-15-amd64 linux-headers-5.10.0-15-common | ||
+ | Use 'apt autoremove' | ||
+ | The following additional packages will be installed: | ||
+ | python3-distro-info python3-software-properties unattended-upgrades | ||
+ | Suggested packages: | ||
+ | bsd-mailx default-mta | mail-transport-agent needrestart powermgmt-base | ||
+ | The following NEW packages will be installed: | ||
+ | apt-transport-https curl python3-distro-info python3-software-properties | ||
+ | software-properties-common unattended-upgrades | ||
+ | 0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded. | ||
+ | Need to get 661 kB of archives. | ||
+ | After this operation, 1,567 kB of additional disk space will be used. | ||
+ | Do you want to continue? [Y/n] y | ||
+ | </ | ||
+ | |||
+ | Téléchargez la clef GPG officielle de docker : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)). | ||
+ | OK | ||
+ | </ | ||
+ | |||
+ | Vérifiez que l'ID de la clef est **9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88** : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)). | ||
+ | pub | ||
+ | 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 | ||
+ | uid [ unknown] Docker Release (CE deb) < | ||
+ | sub | ||
+ | </ | ||
+ | |||
+ | Ajoutez le dépôt **stable** de docker : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **Important** - Notez que la commande **lsb_release -cs** retourne le nom de la distribution Debian, à savoir dans ce cas **stretch**. | ||
+ | </ | ||
+ | |||
+ | Installez maintenant le paquet **docker-ce** : | ||
+ | |||
+ | < | ||
+ | root@debian11docker: | ||
+ | ... | ||
+ | root@debian11: | ||
+ | Reading package lists... Done | ||
+ | Building dependency tree... Done | ||
+ | Reading state information... Done | ||
+ | The following packages were automatically installed and are no longer required: | ||
+ | libopengl0 linux-headers-5.10.0-15-amd64 linux-headers-5.10.0-15-common | ||
+ | Use 'apt autoremove' | ||
+ | The following additional packages will be installed: | ||
+ | containerd.io docker-buildx-plugin docker-ce-cli docker-ce-rootless-extras | ||
+ | docker-compose-plugin git git-man liberror-perl libslirp0 pigz slirp4netns | ||
+ | Suggested packages: | ||
+ | aufs-tools cgroupfs-mount | cgroup-lite git-daemon-run | git-daemon-sysvinit | ||
+ | git-doc git-el git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn | ||
+ | The following NEW packages will be installed: | ||
+ | containerd.io docker-buildx-plugin docker-ce docker-ce-cli | ||
+ | docker-ce-rootless-extras docker-compose-plugin git git-man liberror-perl | ||
+ | libslirp0 pigz slirp4netns | ||
+ | 0 upgraded, 12 newly installed, 0 to remove and 0 not upgraded. | ||
+ | Need to get 121 MB of archives. | ||
+ | After this operation, 452 MB of additional disk space will be used. | ||
+ | Do you want to continue? [Y/n] y | ||
+ | </ | ||
+ | |||
+ | Dernièrement, | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | Client: Docker Engine - Community | ||
+ | | ||
+ | API version: | ||
+ | Go version: | ||
+ | Git commit: | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | Server: Docker Engine - Community | ||
+ | | ||
+ | Version: | ||
+ | API version: | ||
+ | Go version: | ||
+ | Git commit: | ||
+ | Built: | ||
+ | OS/ | ||
+ | Experimental: | ||
+ | | ||
+ | Version: | ||
+ | GitCommit: | ||
+ | runc: | ||
+ | Version: | ||
+ | GitCommit: | ||
+ | | ||
+ | Version: | ||
+ | GitCommit: | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **Important** - Notez que le paquet docker-ce a besoin des paquets **containerd.io** et **docker-ce-cli**. Notez aussi que la procédure ci-dessus installe la version la plus récente de Docker. | ||
+ | </ | ||
+ | |||
+ | Dans le cas où vous souhaitez installer une version différente, | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | Dans le cas où vous souhaiteriez installer la version **24.0.1** de Docker, la commande d’installation deviendrait : | ||
+ | |||
+ | < | ||
+ | # apt-get install docker-ce=5: | ||
+ | </ | ||
+ | |||
+ | Si vous préférez utiliser le script d' | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **Important** - Notez que ces scripts ne doivent pas être utilisés dans un environnement de production. | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | |||
+ | root@debian11: | ||
+ | get-docker.sh | ||
+ | </ | ||
+ | |||
+ | Ensuite, il convient d' | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | |||
+ | root@debian11: | ||
+ | # Executing docker install script, commit: c2de0811708b6d9015ed1a2c80f02c9b70c8ce7b | ||
+ | Warning: the " | ||
+ | |||
+ | If you already have Docker installed, this script can cause trouble, which is | ||
+ | why we're displaying this warning and provide the opportunity to cancel the | ||
+ | installation. | ||
+ | |||
+ | If you installed the current Docker package using this script and are using it | ||
+ | again to update Docker, you can safely ignore this message. | ||
+ | |||
+ | You may press Ctrl+C now to abort this script. | ||
+ | + sleep 20 | ||
+ | ^C | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **Important** - Notez l' | ||
+ | </ | ||
+ | |||
+ | Démarrez un conteneur de l' | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | Unable to find image ' | ||
+ | latest: Pulling from library/ | ||
+ | 719385e32844: | ||
+ | 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 50%> | ||
+ | **Important** - Notez que si l' | ||
+ | </ | ||
+ | |||
+ | ===1.1.2 - CentOS 8=== | ||
+ | |||
+ | Connectez-vous à votre VM **CentOS_10.0.3.45_SSH** à partir de votre VM **Debian_10.0.3.46_SSH** : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | The authenticity of host ' | ||
+ | ECDSA key fingerprint is SHA256: | ||
+ | Are you sure you want to continue connecting (yes/ | ||
+ | Warning: Permanently added ' | ||
+ | trainee@10.0.3.45' | ||
+ | Activate the web console with: systemctl enable --now cockpit.socket | ||
+ | |||
+ | Last login: Wed Nov 15 05:24:16 2023 from 10.0.3.1 | ||
+ | [trainee@centos8 ~]$ | ||
+ | </ | ||
+ | |||
+ | Devenez root : | ||
+ | |||
+ | < | ||
+ | [trainee@centos8 ~]$ su - | ||
+ | Password: fenestros | ||
+ | [root@centos8 ~]# | ||
+ | </ | ||
+ | |||
+ | Ajouter le dépôt de docker : | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# yum install -y yum-utils | ||
+ | Last metadata expiration check: 0:05:37 ago on Fri 18 Aug 2023 15:53:49 CEST. | ||
+ | Package yum-utils-4.0.21-3.el8.noarch is already installed. | ||
+ | Dependencies resolved. | ||
+ | Nothing to do. | ||
+ | Complete! | ||
+ | |||
+ | [root@centos8 ~]# yum-config-manager --add-repo https:// | ||
+ | Adding repo from: https:// | ||
+ | </ | ||
+ | |||
+ | Supprimez le paquet **podman** et installez **Docker** : | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# yum remove podman | ||
+ | Dependencies resolved. | ||
+ | ====================================================================================== | ||
+ | | ||
+ | ====================================================================================== | ||
+ | Removing: | ||
+ | | ||
+ | Removing dependent packages: | ||
+ | | ||
+ | Removing unused dependencies: | ||
+ | | ||
+ | | ||
+ | |||
+ | Transaction Summary | ||
+ | ====================================================================================== | ||
+ | Remove | ||
+ | |||
+ | Freed space: 49 M | ||
+ | Is this ok [y/N]: y | ||
+ | Running transaction check | ||
+ | Transaction check succeeded. | ||
+ | Running transaction test | ||
+ | Transaction test succeeded. | ||
+ | Running transaction | ||
+ | Preparing | ||
+ | Running scriptlet: cockpit-podman-33-1.module_el8.5.0+890+6b136101.noarch | ||
+ | Erasing | ||
+ | Erasing | ||
+ | Running scriptlet: podman-3.3.1-9.module_el8.5.0+988+b1f0b741.x86_64 | ||
+ | Erasing | ||
+ | Erasing | ||
+ | Running scriptlet: conmon-2: | ||
+ | Verifying | ||
+ | Verifying | ||
+ | Verifying | ||
+ | Verifying | ||
+ | Installed products updated. | ||
+ | |||
+ | Removed: | ||
+ | cockpit-podman-33-1.module_el8.5.0+890+6b136101.noarch | ||
+ | conmon-2: | ||
+ | podman-3.3.1-9.module_el8.5.0+988+b1f0b741.x86_64 | ||
+ | podman-catatonit-3.3.1-9.module_el8.5.0+988+b1f0b741.x86_64 | ||
+ | |||
+ | Complete! | ||
+ | |||
+ | [root@centos8 ~]# yum install docker-ce docker-ce-cli containerd.io --allowerasing | ||
+ | Last metadata expiration check: 0:05:43 ago on Fri 18 Aug 2023 16:04:20 CEST. | ||
+ | Dependencies resolved. | ||
+ | ====================================================================================== | ||
+ | | ||
+ | ====================================================================================== | ||
+ | Installing: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | Installing dependencies: | ||
+ | | ||
+ | | ||
+ | Installing weak dependencies: | ||
+ | | ||
+ | | ||
+ | Removing dependent packages: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | Transaction Summary | ||
+ | ====================================================================================== | ||
+ | Install | ||
+ | Remove | ||
+ | |||
+ | Total download size: 96 M | ||
+ | Is this ok [y/N]: y | ||
+ | |||
+ | Transaction Summary | ||
+ | ====================================================================================== | ||
+ | Install | ||
+ | Remove | ||
+ | |||
+ | Total download size: 96 M | ||
+ | Is this ok [y/N]: y | ||
+ | Downloading Packages: | ||
+ | (1/7): libcgroup-0.41-19.el8.x86_64.rpm | ||
+ | (2/7): docker-buildx-plugin-0.11.2-1.el8.x86_64.rpm | ||
+ | (3/7): docker-ce-cli-24.0.5-1.el8.x86_64.rpm | ||
+ | (4/7): docker-ce-24.0.5-1.el8.x86_64.rpm | ||
+ | (5/7): containerd.io-1.6.22-3.1.el8.x86_64.rpm | ||
+ | (6/7): docker-ce-rootless-extras-24.0.5-1.el8.x86_64. 322 kB/s | 4.9 MB | ||
+ | (7/7): docker-compose-plugin-2.20.2-1.el8.x86_64.rpm | ||
+ | -------------------------------------------------------------------------------------- | ||
+ | Total 3.7 MB/s | 96 MB | ||
+ | Docker CE Stable - x86_64 | ||
+ | Importing GPG key 0x621E9F35: | ||
+ | | ||
+ | | ||
+ | | ||
+ | Is this ok [y/N]: y | ||
+ | Key imported successfully | ||
+ | Running transaction check | ||
+ | Transaction check succeeded. | ||
+ | Running transaction test | ||
+ | Transaction test succeeded. | ||
+ | Running transaction | ||
+ | Preparing | ||
+ | Installing | ||
+ | Running scriptlet: docker-compose-plugin-2.20.2-1.el8.x86_64 | ||
+ | Installing | ||
+ | Running scriptlet: docker-buildx-plugin-0.11.2-1.el8.x86_64 | ||
+ | Installing | ||
+ | Running scriptlet: docker-ce-cli-1: | ||
+ | Installing | ||
+ | Running scriptlet: containerd.io-1.6.22-3.1.el8.x86_64 | ||
+ | Running scriptlet: libcgroup-0.41-19.el8.x86_64 | ||
+ | Installing | ||
+ | Running scriptlet: libcgroup-0.41-19.el8.x86_64 | ||
+ | Installing | ||
+ | Running scriptlet: docker-ce-rootless-extras-24.0.5-1.el8.x86_64 | ||
+ | Installing | ||
+ | Running scriptlet: docker-ce-3: | ||
+ | Erasing | ||
+ | Erasing | ||
+ | Obsoleting | ||
+ | Running scriptlet: runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64 | ||
+ | Verifying | ||
+ | Verifying | ||
+ | Verifying | ||
+ | Verifying | ||
+ | Verifying | ||
+ | Verifying | ||
+ | Verifying | ||
+ | Verifying | ||
+ | Verifying | ||
+ | Verifying | ||
+ | Installed products updated. | ||
+ | |||
+ | Installed: | ||
+ | containerd.io-1.6.22-3.1.el8.x86_64 | ||
+ | docker-buildx-plugin-0.11.2-1.el8.x86_64 | ||
+ | docker-ce-3: | ||
+ | docker-ce-cli-1: | ||
+ | docker-ce-rootless-extras-24.0.5-1.el8.x86_64 | ||
+ | docker-compose-plugin-2.20.2-1.el8.x86_64 | ||
+ | libcgroup-0.41-19.el8.x86_64 | ||
+ | Removed: | ||
+ | buildah-1.22.3-2.module_el8.5.0+911+f19012f9.x86_64 | ||
+ | containers-common-2: | ||
+ | |||
+ | Complete! | ||
+ | </ | ||
+ | |||
+ | Démarrez ensuite le service docker : | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl status docker | ||
+ | ● docker.service - Docker Application Container Engine | ||
+ | | ||
+ | | ||
+ | Docs: https:// | ||
+ | [q] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
+ | |||
+ | [root@centos8 ~]# systemctl start docker | ||
+ | |||
+ | [root@centos8 ~]# systemctl status docker | ||
+ | ● docker.service - Docker Application Container Engine | ||
+ | | ||
+ | | ||
+ | Docs: https:// | ||
+ | Main PID: 49974 (dockerd) | ||
+ | Tasks: 13 | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | Aug 18 16:19:33 centos8.ittraining.loc systemd[1]: Starting Docker Application Contai> | ||
+ | Aug 18 16:19:33 centos8.ittraining.loc dockerd[49974]: | ||
+ | Aug 18 16:19:33 centos8.ittraining.loc dockerd[49974]: | ||
+ | Aug 18 16:19:34 centos8.ittraining.loc dockerd[49974]: | ||
+ | Aug 18 16:19:35 centos8.ittraining.loc dockerd[49974]: | ||
+ | Aug 18 16:19:35 centos8.ittraining.loc dockerd[49974]: | ||
+ | Aug 18 16:19:35 centos8.ittraining.loc dockerd[49974]: | ||
+ | Aug 18 16:19:35 centos8.ittraining.loc dockerd[49974]: | ||
+ | Aug 18 16:19:35 centos8.ittraining.loc systemd[1]: Started Docker Application Contain> | ||
+ | [q] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
+ | [root@centos8 ~]# | ||
+ | </ | ||
+ | |||
+ | Dans le cas où vous souhaitez installer une version différente, | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# yum list docker-ce --showduplicates | sort -r | ||
+ | Last metadata expiration check: 0:03:42 ago on Fri 18 Aug 2023 16:11:47 CEST. | ||
+ | Installed Packages | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | docker-ce.x86_64 3: | ||
+ | Available Packages | ||
+ | |||
+ | [root@centos8 ~]# yum list docker-ce-cli --showduplicates | sort -r | ||
+ | Last metadata expiration check: 0:08:33 ago on Thu 14 Dec 2023 09:52:33 EST. | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | docker-ce-cli.x86_64 | ||
+ | Available Packages | ||
+ | </ | ||
+ | |||
+ | Dans le cas où vous souhaiteriez installer la version **24.0.4** de Docker, la commande d’installation deviendrait : | ||
+ | |||
+ | < | ||
+ | # yum install docker-ce-3: | ||
+ | </ | ||
+ | |||
+ | Si vous préférez utiliser le script d' | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **Important** - Notez que ces scripts ne doivent pas être utilisés dans un environnement de production. | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# curl -fsSL https:// | ||
+ | |||
+ | [root@centos8 ~]# ls | ||
+ | anaconda-ks.cfg | ||
+ | CentOS-8.1.1911-x86_64-boot.iso | ||
+ | Desktop | ||
+ | Documents | ||
+ | </ | ||
+ | |||
+ | Ensuite, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# chmod +x get-docker.sh | ||
+ | |||
+ | [root@centos8 ~]# ./ | ||
+ | # Executing docker install script, commit: c2de0811708b6d9015ed1a2c80f02c9b70c8ce7b | ||
+ | Warning: the " | ||
+ | |||
+ | If you already have Docker installed, this script can cause trouble, which is | ||
+ | why we're displaying this warning and provide the opportunity to cancel the | ||
+ | installation. | ||
+ | |||
+ | If you installed the current Docker package using this script and are using it | ||
+ | again to update Docker, you can safely ignore this message. | ||
+ | |||
+ | You may press Ctrl+C now to abort this script. | ||
+ | + sleep 20 | ||
+ | ^C | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **Important** - Notez l' | ||
+ | </ | ||
+ | |||
+ | Démarrez un conteneur de l' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# docker run hello-world | ||
+ | Unable to find image ' | ||
+ | latest: Pulling from library/ | ||
+ | 719385e32844: | ||
+ | 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 50%> | ||
+ | **Important** - Notez que si l' | ||
+ | </ | ||
+ | |||
+ | ====1.2 - Démarrer un Conteneur==== | ||
+ | |||
+ | Démarrez un conteneur de l' | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | Unable to find image ' | ||
+ | latest: Pulling from library/ | ||
+ | b237fe92c417: | ||
+ | Digest: sha256: | ||
+ | Status: Downloaded newer image for ubuntu: | ||
+ | |||
+ | root@83b0d8979a33:/# | ||
+ | bin boot dev etc home lib lib32 lib64 libx32 | ||
+ | |||
+ | root@83b0d8979a33:/# | ||
+ | DISTRIB_ID=Ubuntu | ||
+ | DISTRIB_RELEASE=22.04 | ||
+ | DISTRIB_CODENAME=jammy | ||
+ | DISTRIB_DESCRIPTION=" | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **Important** - Notez que dans ce cas le conteneur est lancé avec comme argument **bash** qui lancera /bin/bash dans le conteneur. | ||
+ | </ | ||
+ | |||
+ | Consulter la liste des paquets installés dans le conteneur ubuntu : | ||
+ | |||
+ | < | ||
+ | root@83b0d8979a33:/# | ||
+ | Desired=Unknown/ | ||
+ | | Status=Not/ | ||
+ | |/ Err? | ||
+ | ||/ Name Version | ||
+ | +++-=======================-=======================================-============-======================================================================== | ||
+ | ii adduser | ||
+ | ii apt | ||
+ | ii base-files | ||
+ | ii base-passwd | ||
+ | ii bash 5.1-6ubuntu1 | ||
+ | ii bsdutils | ||
+ | ii coreutils | ||
+ | ii dash 0.5.11+git20210903+057cd650a4ed-3build1 amd64 POSIX-compliant shell | ||
+ | ii debconf | ||
+ | ii debianutils | ||
+ | ii diffutils | ||
+ | ii dpkg 1.21.1ubuntu2.2 | ||
+ | ii e2fsprogs | ||
+ | ii findutils | ||
+ | ii gcc-12-base: | ||
+ | ii gpgv 2.2.27-3ubuntu2.1 | ||
+ | ii grep 3.7-1build1 | ||
+ | ii gzip 1.10-4ubuntu4.1 | ||
+ | ii hostname | ||
+ | ii init-system-helpers | ||
+ | ii libacl1: | ||
+ | ii libapt-pkg6.0: | ||
+ | ii libattr1: | ||
+ | ii libaudit-common | ||
+ | ii libaudit1: | ||
+ | ii libblkid1: | ||
+ | ii libbz2-1.0: | ||
+ | ii libc-bin | ||
+ | ii libc6: | ||
+ | ii libcap-ng0: | ||
+ | ii libcap2: | ||
+ | ii libcom-err2: | ||
+ | ii libcrypt1: | ||
+ | ii libdb5.3: | ||
+ | ii libdebconfclient0: | ||
+ | ii libext2fs2: | ||
+ | ii libffi8: | ||
+ | ii libgcc-s1: | ||
+ | ii libgcrypt20: | ||
+ | ii libgmp10: | ||
+ | ii libgnutls30: | ||
+ | ii libgpg-error0: | ||
+ | ii libgssapi-krb5-2: | ||
+ | ii libhogweed6: | ||
+ | ii libidn2-0: | ||
+ | ii libk5crypto3: | ||
+ | ii libkeyutils1: | ||
+ | ii libkrb5-3: | ||
+ | ii libkrb5support0: | ||
+ | ii liblz4-1: | ||
+ | ii liblzma5: | ||
+ | ii libmount1: | ||
+ | ii libncurses6: | ||
+ | ii libncursesw6: | ||
+ | ii libnettle8: | ||
+ | ii libnsl2: | ||
+ | ii libp11-kit0: | ||
+ | ii libpam-modules: | ||
+ | ii libpam-modules-bin | ||
+ | ii libpam-runtime | ||
+ | ii libpam0g: | ||
+ | ii libpcre2-8-0: | ||
+ | ii libpcre3: | ||
+ | ii libprocps8: | ||
+ | ii libseccomp2: | ||
+ | ii libselinux1: | ||
+ | ii libsemanage-common | ||
+ | ii libsemanage2: | ||
+ | ii libsepol2: | ||
+ | ii libsmartcols1: | ||
+ | ii libss2: | ||
+ | ii libssl3: | ||
+ | ii libstdc++6: | ||
+ | ii libsystemd0: | ||
+ | ii libtasn1-6: | ||
+ | ii libtinfo6: | ||
+ | ii libtirpc-common | ||
+ | ii libtirpc3: | ||
+ | ii libudev1: | ||
+ | ii libunistring2: | ||
+ | ii libuuid1: | ||
+ | ii libxxhash0: | ||
+ | ii libzstd1: | ||
+ | ii login | ||
+ | ii logsave | ||
+ | ii lsb-base | ||
+ | ii mawk 1.3.4.20200120-3 | ||
+ | ii mount | ||
+ | ii ncurses-base | ||
+ | ii ncurses-bin | ||
+ | ii passwd | ||
+ | ii perl-base | ||
+ | ii procps | ||
+ | ii sed | ||
+ | ii sensible-utils | ||
+ | ii sysvinit-utils | ||
+ | ii tar | ||
+ | ii ubuntu-keyring | ||
+ | ii usrmerge | ||
+ | ii util-linux | ||
+ | ii zlib1g: | ||
+ | root@83b0d8979a33:/# | ||
+ | exit | ||
+ | root@debian11: | ||
+ | </ | ||
+ | |||
+ | Les options de la commande docker run peuvent être visualisées avec la commande : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | |||
+ | Usage: | ||
+ | |||
+ | Create and run a new container from an image | ||
+ | |||
+ | Aliases: | ||
+ | docker container run, docker run | ||
+ | |||
+ | Options: | ||
+ | --add-host list Add a custom host-to-IP mapping (host:ip) | ||
+ | --annotation map Add an annotation to the container (passed through to the OCI runtime) (default map[]) | ||
+ | -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 | ||
+ | --cgroupns string | ||
+ | ' | ||
+ | ' | ||
+ | '': | ||
+ | default-cgroupns-mode option on the daemon (default) | ||
+ | --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 | ||
+ | --domainname string | ||
+ | --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 | ||
+ | --gpus gpu-request | ||
+ | --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 network | ||
+ | --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) | ||
+ | --platform string | ||
+ | --privileged | ||
+ | -p, --publish list | ||
+ | -P, --publish-all | ||
+ | --pull string | ||
+ | -q, --quiet | ||
+ | --read-only | ||
+ | --restart string | ||
+ | --rm | ||
+ | --runtime string | ||
+ | --security-opt list Security Options | ||
+ | --shm-size bytes Size of /dev/shm | ||
+ | --sig-proxy | ||
+ | --stop-signal string | ||
+ | --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 | ||
+ | --userns 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 - Consulter la Liste des Conteneurs et Images==== | ||
+ | |||
+ | Pour consulter tous les conteneurs, utilisez la commande **docker ps** avec l' | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | 83b0d8979a33 | ||
+ | 5d17db3bbb20 | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **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 **docker images** : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | REPOSITORY | ||
+ | ubuntu | ||
+ | hello-world | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **Important** - Notez que chaque image est référencée par son IMAGE ID. | ||
+ | </ | ||
+ | |||
+ | ====1.4 - Rechercher une Image dans un Dépôt==== | ||
+ | |||
+ | Pour rechercher une image docker dans le dépôt par défaut, utilisez la commande **docker search** : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | NAME DESCRIPTION | ||
+ | centos | ||
+ | kasmweb/ | ||
+ | couchbase/ | ||
+ | dokken/ | ||
+ | eclipse/ | ||
+ | dokken/ | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **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' | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | 83b0d8979a33 | ||
+ | 5d17db3bbb20 | ||
+ | |||
+ | root@debian11: | ||
+ | upbeat_diffie | ||
+ | |||
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | 5d17db3bbb20 | ||
+ | |||
+ | root@debian11: | ||
+ | REPOSITORY | ||
+ | ubuntu | ||
+ | hello-world | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **Important** - Notez que dans le cas de l' | ||
+ | </ | ||
+ | |||
+ | ====1.6 -Créer une Image à partir d'un Conteneur Modifié=== | ||
+ | |||
+ | Modifier un conteneur d'une image : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | |||
+ | root@4377355f88c2:/# | ||
+ | bin boot dev etc home lib lib32 lib64 libx32 | ||
+ | |||
+ | root@4377355f88c2:/# | ||
+ | |||
+ | root@4377355f88c2:/# | ||
+ | bin boot dev etc lib lib32 lib64 libx32 | ||
+ | |||
+ | root@4377355f88c2:/# | ||
+ | exit | ||
+ | root@debian11: | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **Important** - Notez ici la suppression du répertoire **home** dans le conteneur **4377355f88c2**. | ||
+ | </ | ||
+ | |||
+ | Consultez la différence entre le conteneur et l' | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | 4377355f88c2 | ||
+ | 5d17db3bbb20 | ||
+ | |||
+ | root@debian11: | ||
+ | C /root | ||
+ | A / | ||
+ | D /home | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **Important** - La sortie de la commande **docker diff** comporte des lettres dont les significations sont les suivantes : C = Create, D = Delete, A = Add. | ||
+ | </ | ||
+ | |||
+ | Créez un autre conteneur à partir de l' | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | |||
+ | root@e4caf92a5ceb:/# | ||
+ | bin boot dev etc home lib lib32 lib64 libx32 | ||
+ | |||
+ | root@e4caf92a5ceb:/# | ||
+ | exit | ||
+ | |||
+ | root@debian11: | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **Important** - Dans ce nouveau conteneur, le répertoire **/home** est présent compte tenu du fait qu'il a été généré à partir de l' | ||
+ | </ | ||
+ | |||
+ | Créez maintenant l' | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | e4caf92a5ceb | ||
+ | 4377355f88c2 | ||
+ | 5d17db3bbb20 | ||
+ | |||
+ | root@debian11: | ||
+ | sha256: | ||
+ | |||
+ | root@debian11: | ||
+ | REPOSITORY | ||
+ | ubuntu_1 | ||
+ | ubuntu | ||
+ | hello-world | ||
+ | |||
+ | root@debian11: | ||
+ | </ | ||
+ | |||
+ | ====1.7 - Supprimer une Image==== | ||
+ | |||
+ | Créez maintenant un conteneur à partir de la nouvelle image **ubuntu_1** : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | |||
+ | root@86e777ebaf2b:/# | ||
+ | bin boot dev etc lib lib32 lib64 libx32 | ||
+ | |||
+ | root@86e777ebaf2b:/# | ||
+ | exit | ||
+ | |||
+ | root@debian11: | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **Important** - Notez l' | ||
+ | </ | ||
+ | |||
+ | Essayez de supprimer l' | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | Error response from daemon: conflict: unable to remove repository reference " | ||
+ | |||
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | 86e777ebaf2b | ||
+ | e4caf92a5ceb | ||
+ | 4377355f88c2 | ||
+ | 5d17db3bbb20 | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **Important** - Notez qu'il n'est pas possible de supprimer l' | ||
+ | </ | ||
+ | |||
+ | Supprimez donc le conteneur identifié par le message d' | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | focused_colden | ||
+ | |||
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | e4caf92a5ceb | ||
+ | 4377355f88c2 | ||
+ | 5d17db3bbb20 | ||
+ | |||
+ | root@debian11: | ||
+ | Untagged: ubuntu_1: | ||
+ | Deleted: sha256: | ||
+ | Deleted: sha256: | ||
+ | |||
+ | root@debian11: | ||
+ | REPOSITORY | ||
+ | ubuntu | ||
+ | hello-world | ||
+ | </ | ||
+ | |||
+ | Pour pouvoir supprimer tous les conteneurs, listez-les par leur **Container ID** : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | e4caf92a5ceb | ||
+ | 4377355f88c2 | ||
+ | 5d17db3bbb20 | ||
+ | </ | ||
+ | |||
+ | Supprimer toutes les conteneurs : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | e4caf92a5ceb | ||
+ | 4377355f88c2 | ||
+ | 5d17db3bbb20 | ||
+ | |||
+ | root@debian11: | ||
+ | |||
+ | root@debian11: | ||
+ | </ | ||
+ | |||
+ | Pour supprimer un conteneur dès la fin de son exécution, utilisez l' | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | |||
+ | root@3b3d4d7be82b:/# | ||
+ | bin boot dev etc home lib lib32 lib64 libx32 | ||
+ | |||
+ | root@3b3d4d7be82b:/# | ||
+ | exit | ||
+ | |||
+ | root@debian11: | ||
+ | |||
+ | root@debian11: | ||
+ | </ | ||
+ | |||
+ | ====1.8 - Créer un Conteneur avec un Nom Spécifique==== | ||
+ | |||
+ | Créez maintenant un conteneur avec un nom spécifique : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | |||
+ | root@d838ea83033e:/# | ||
+ | bin boot dev etc home lib lib32 lib64 libx32 | ||
+ | |||
+ | root@d838ea83033e:/# | ||
+ | exit | ||
+ | |||
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | d838ea83033e | ||
+ | </ | ||
+ | |||
+ | Pour obtenir de l' | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | [ | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | 59, | ||
+ | 210 | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | "/ | ||
+ | "/ | ||
+ | "/ | ||
+ | "/ | ||
+ | "/ | ||
+ | "/ | ||
+ | "/ | ||
+ | "/ | ||
+ | "/ | ||
+ | "/ | ||
+ | ], | ||
+ | " | ||
+ | "/ | ||
+ | "/ | ||
+ | "/ | ||
+ | "/ | ||
+ | "/ | ||
+ | ] | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ], | ||
+ | " | ||
+ | "/ | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | ] | ||
+ | </ | ||
+ | |||
+ | ====1.9 - Exécuter une Commande dans un Conteneur==== | ||
+ | |||
+ | Pour exécuter une commande spécifique dans un conteneur, passez la commande en argument : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | PATH=/ | ||
+ | HOSTNAME=9b7b7547c023 | ||
+ | HOME=/root | ||
+ | |||
+ | root@debian11: | ||
+ | </ | ||
+ | |||
+ | ====1.10 - Injecter des Variables d' | ||
+ | |||
+ | Pour injecter une ou des variables d' | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | |||
+ | root@debian11: | ||
+ | EDITOR=vim | ||
+ | HOSTNAME=ubuntudocker | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | PATH=/ | ||
+ | HOSTNAME=ubuntudocker | ||
+ | EDITOR=vim | ||
+ | HOME=/root | ||
+ | |||
+ | root@debian11: | ||
+ | </ | ||
+ | |||
+ | ====1.11 - Modifier le Nom d' | ||
+ | |||
+ | Pour modifier le nom d' | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | |||
+ | root@ubuntudocker:/# | ||
+ | ubuntudocker | ||
+ | |||
+ | root@ubuntudocker:/# | ||
+ | exit | ||
+ | </ | ||
+ | |||
+ | ====1.12 - Mapper des Ports d'un Conteneur===== | ||
+ | |||
+ | Démarrer un conteneur de nginx sur le port localhost 81 : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | Unable to find image ' | ||
+ | latest: Pulling from library/ | ||
+ | 52d2b7f179e3: | ||
+ | fd9f026c6310: | ||
+ | 055fa98b4363: | ||
+ | 96576293dd29: | ||
+ | a7c4092be904: | ||
+ | e3b6889c8954: | ||
+ | da761d9a302b: | ||
+ | Digest: sha256: | ||
+ | Status: Downloaded newer image for nginx: | ||
+ | |||
+ | ^C | ||
+ | |||
+ | root@debian11: | ||
+ | </ | ||
+ | |||
+ | Notez que c'est bloquant. Le fait d' | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | 37cb0af1e97f | ||
+ | d838ea83033e | ||
+ | </ | ||
+ | |||
+ | ====1.13 - Démarrer un Conteneur en mode Détaché==== | ||
+ | |||
+ | Démarrez maintenant le conteneur de nginx en mode détaché grâce à l' | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | 5c2fe852965f700fff2d11baff034557c4956a7cd5eb54c51967d362415a76b4 | ||
+ | |||
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | 5c2fe852965f | ||
+ | 37cb0af1e97f | ||
+ | d838ea83033e | ||
+ | </ | ||
+ | |||
+ | ====1.14 - Accèder aux Services d'un Conteneur de l' | ||
+ | |||
+ | Installez le navigateur texte **lynx** : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | Reading package lists... Done | ||
+ | Building dependency tree... Done | ||
+ | Reading state information... Done | ||
+ | The following packages were automatically installed and are no longer required: | ||
+ | libopengl0 linux-headers-5.10.0-15-amd64 linux-headers-5.10.0-15-common | ||
+ | Use 'apt autoremove' | ||
+ | The following additional packages will be installed: | ||
+ | lynx-common | ||
+ | The following NEW packages will be installed: | ||
+ | lynx lynx-common | ||
+ | 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. | ||
+ | Need to get 1,844 kB of archives. | ||
+ | After this operation, 5,768 kB of additional disk space will be used. | ||
+ | Do you want to continue? [Y/n] y | ||
+ | </ | ||
+ | |||
+ | Vérifiez que nginx répond aux requetes : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | | ||
+ | |||
+ | 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. | ||
+ | |||
+ | References | ||
+ | |||
+ | 1. http:// | ||
+ | 2. http:// | ||
+ | |||
+ | root@debian11: | ||
+ | </ | ||
+ | |||
+ | ====1.15 - Arrêter et Démarrer un Conteneur==== | ||
+ | |||
+ | Arrêtez le conteneur nginx : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | 5c2fe852965f | ||
+ | 37cb0af1e97f | ||
+ | d838ea83033e | ||
+ | ittraining | ||
+ | root@debian11: | ||
+ | 5c2f | ||
+ | |||
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | 5c2fe852965f | ||
+ | 37cb0af1e97f | ||
+ | d838ea83033e | ||
+ | </ | ||
+ | |||
+ | Démarrez de nouveau le conteneur de nginx : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | 5c2f | ||
+ | |||
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | 5c2fe852965f | ||
+ | 37cb0af1e97f | ||
+ | d838ea83033e | ||
+ | </ | ||
+ | |||
+ | ====1.16 - Utiliser des Signaux avec un Conteneur==== | ||
+ | |||
+ | Utilisez un signal pour tuer le processus du conteneur de nginx : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | 5c2f | ||
+ | |||
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | 5c2fe852965f | ||
+ | 37cb0af1e97f | ||
+ | d838ea83033e | ||
+ | </ | ||
+ | |||
+ | Redémarrez le conteneur : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | 5c2f | ||
+ | |||
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | 5c2fe852965f | ||
+ | 37cb0af1e97f | ||
+ | d838ea83033e | ||
+ | |||
+ | root@debian11: | ||
+ | 5c2f | ||
+ | |||
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | 5c2fe852965f | ||
+ | 37cb0af1e97f | ||
+ | d838ea83033e | ||
+ | </ | ||
+ | |||
+ | ====1.17 - Forcer la Suppression d'un Conteneur en cours d' | ||
+ | |||
+ | Supprimez un conteneur en cours d' | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | Error response from daemon: You cannot remove a running container 5c2fe852965f700fff2d11baff034557c4956a7cd5eb54c51967d362415a76b4. Stop the container before attempting removal or force remove | ||
+ | |||
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | 5c2fe852965f | ||
+ | 37cb0af1e97f | ||
+ | d838ea83033e | ||
+ | |||
+ | root@debian11: | ||
+ | 5c2f | ||
+ | |||
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | 37cb0af1e97f | ||
+ | d838ea83033e | ||
+ | </ | ||
+ | |||
+ | ===1.18 - Utilisation Simple d'un Volume=== | ||
+ | |||
+ | Créez le fichier index.html et placez-le dans le répertoire /root/www : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | |||
+ | root@debian11: | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | root@debian11: | ||
+ | |||
+ | root@debian11: | ||
+ | </ | ||
+ | |||
+ | Indiquez au conteneur que son répertoire **/ | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | 5bec576b4b69b3dbd4cb58305a80d5ac94d42312b486e99dac94f82ba6541e3c | ||
+ | |||
+ | root@debian11: | ||
+ | Accueil du site nginx | ||
+ | |||
+ | root@debian11: | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **Important** - Notez ici l' | ||
+ | </ | ||
+ | |||
+ | ====1.19 - Télécharger une image sans créer un conteneur==== | ||
+ | |||
+ | Téléchargez l' | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | Using default tag: latest | ||
+ | latest: Pulling from library/ | ||
+ | a1d0c7532777: | ||
+ | Digest: sha256: | ||
+ | Status: Downloaded newer image for centos: | ||
+ | docker.io/ | ||
+ | </ | ||
+ | |||
+ | Vérifiez le contenu de l' | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | |||
+ | [root@b45b7b136f06 /]# cat / | ||
+ | CentOS Linux release 8.4.2105 | ||
+ | |||
+ | [root@b45b7b136f06 /]# rpm -qa | more | ||
+ | crypto-policies-20210209-1.gitbfb6bed.el8_3.noarch | ||
+ | python3-pip-wheel-9.0.3-19.el8.noarch | ||
+ | ncurses-base-6.1-7.20180224.el8.noarch | ||
+ | dnf-data-4.4.2-11.el8.noarch | ||
+ | dhcp-common-4.3.6-44.0.1.el8.noarch | ||
+ | centos-gpg-keys-8-2.el8.noarch | ||
+ | centos-linux-repos-8-2.el8.noarch | ||
+ | filesystem-3.8-3.el8.x86_64 | ||
+ | pcre2-10.32-2.el8.x86_64 | ||
+ | ncurses-libs-6.1-7.20180224.el8.x86_64 | ||
+ | glibc-common-2.28-151.el8.x86_64 | ||
+ | bash-4.4.19-14.el8.x86_64 | ||
+ | zlib-1.2.11-17.el8.x86_64 | ||
+ | bzip2-libs-1.0.6-26.el8.x86_64 | ||
+ | libgpg-error-1.31-1.el8.x86_64 | ||
+ | elfutils-libelf-0.182-3.el8.x86_64 | ||
+ | libcom_err-1.45.6-1.el8.x86_64 | ||
+ | libxml2-2.9.7-9.el8.x86_64 | ||
+ | expat-2.2.5-4.el8.x86_64 | ||
+ | libuuid-2.32.1-27.el8.x86_64 | ||
+ | chkconfig-1.13-2.el8.x86_64 | ||
+ | gmp-6.1.2-10.el8.x86_64 | ||
+ | libattr-2.4.48-3.el8.x86_64 | ||
+ | coreutils-single-8.30-8.el8.x86_64 | ||
+ | sed-4.5-2.el8.x86_64 | ||
+ | libcap-ng-0.7.9-5.el8.x86_64 | ||
+ | libsmartcols-2.32.1-27.el8.x86_64 | ||
+ | lz4-libs-1.8.3-2.el8.x86_64 | ||
+ | file-libs-5.33-16.el8_3.1.x86_64 | ||
+ | p11-kit-0.23.22-1.el8.x86_64 | ||
+ | cracklib-2.9.6-15.el8.x86_64 | ||
+ | libunistring-0.9.9-3.el8.x86_64 | ||
+ | libassuan-2.5.1-3.el8.x86_64 | ||
+ | keyutils-libs-1.5.10-6.el8.x86_64 | ||
+ | libnl3-3.5.0-1.el8.x86_64 | ||
+ | p11-kit-trust-0.23.22-1.el8.x86_64 | ||
+ | pcre-8.42-4.el8.x86_64 | ||
+ | systemd-libs-239-45.el8.x86_64 | ||
+ | dbus-tools-1.12.8-12.el8.x86_64 | ||
+ | libusbx-1.0.23-4.el8.x86_64 | ||
+ | ca-certificates-2020.2.41-80.0.el8_2.noarch | ||
+ | libdb-5.3.28-40.el8.x86_64 | ||
+ | iproute-5.9.0-4.el8.x86_64 | ||
+ | libdb-utils-5.3.28-40.el8.x86_64 | ||
+ | tpm2-tss-2.3.2-3.el8.x86_64 | ||
+ | xz-5.2.4-3.el8.x86_64 | ||
+ | ethtool-5.8-5.el8.x86_64 | ||
+ | libsemanage-2.9-6.el8.x86_64 | ||
+ | dbus-daemon-1.12.8-12.el8.x86_64 | ||
+ | libfdisk-2.32.1-27.el8.x86_64 | ||
+ | mpfr-3.1.6-1.el8.x86_64 | ||
+ | gnutls-3.6.14-7.el8_3.x86_64 | ||
+ | snappy-1.1.8-3.el8.x86_64 | ||
+ | libmetalink-0.1.3-7.el8.x86_64 | ||
+ | libksba-1.3.5-7.el8.x86_64 | ||
+ | ipcalc-0.2.4-4.el8.x86_64 | ||
+ | libseccomp-2.5.1-1.el8.x86_64 | ||
+ | gawk-4.2.1-2.el8.x86_64 | ||
+ | --More-- | ||
+ | [q] | ||
+ | [root@b45b7b136f06 /]# | ||
+ | </ | ||
+ | |||
+ | ====1.20 - S' | ||
+ | |||
+ | Arretez le conteneur. Démarrez le conteneur puis rattachez-vous au conteneur : | ||
+ | |||
+ | < | ||
+ | [root@b45b7b136f06 /]# exit | ||
+ | exit | ||
+ | |||
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | b45b7b136f06 | ||
+ | 5bec576b4b69 | ||
+ | 37cb0af1e97f | ||
+ | d838ea83033e | ||
+ | |||
+ | root@debian11: | ||
+ | b45b | ||
+ | |||
+ | root@debian11: | ||
+ | |||
+ | [root@b45b7b136f06 /]# ls | ||
+ | bin dev etc home lib lib64 lost+found | ||
+ | |||
+ | [root@b45b7b136f06 /]# | ||
+ | </ | ||
+ | |||
+ | ====1.21 - Installer un logiciel dans le conteneur=== | ||
+ | |||
+ | Réparez les dépôts de CentOS 8 : | ||
+ | |||
+ | < | ||
+ | [root@b45b7b136f06 /]# sed -i ' | ||
+ | |||
+ | [root@b45b7b136f06 /]# sed -i ' | ||
+ | |||
+ | [root@b45b7b136f06 /]# yum upgrade -y | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | Créez le fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@b45b7b136f06 /]# vi / | ||
+ | |||
+ | [root@b45b7b136f06 /]# cat / | ||
+ | [mongodb-org-4.2] | ||
+ | name=MongoDB Repository | ||
+ | baseurl=https:// | ||
+ | gpgcheck=1 | ||
+ | enabled=1 | ||
+ | gpgkey=https:// | ||
+ | name=MongoDB Repository | ||
+ | baseurl=https:// | ||
+ | gpgcheck=1 | ||
+ | enabled=1 | ||
+ | gpgkey=https:// | ||
+ | </ | ||
+ | |||
+ | Installez mongo : | ||
+ | |||
+ | < | ||
+ | [root@b45b7b136f06 /]# yum install -y mongodb-org | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | Démarrez mongod : | ||
+ | |||
+ | < | ||
+ | [root@b45b7b136f06 /]# mongod --config / | ||
+ | [1] 440 | ||
+ | |||
+ | [root@b45b7b136f06 /]# about to fork child process, waiting until server is ready for connections. | ||
+ | forked process: 442 | ||
+ | [Enter] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
+ | [root@b45b7b136f06 /]# child process started successfully, | ||
+ | [Enter] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
+ | [1]+ Done mongod --config / | ||
+ | </ | ||
+ | |||
+ | Vérifiez que mongod est démarré : | ||
+ | |||
+ | < | ||
+ | [root@b45b7b136f06 /]# ps aux | ||
+ | USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | ||
+ | root | ||
+ | root | ||
+ | root | ||
+ | </ | ||
+ | |||
+ | Utilisez le client mongo pour se connecter au serveur : | ||
+ | |||
+ | < | ||
+ | [root@b45b7b136f06 /]# mongo | ||
+ | MongoDB shell version v4.2.24 | ||
+ | connecting to: mongodb:// | ||
+ | Implicit session: session { " | ||
+ | MongoDB server version: 4.2.24 | ||
+ | Welcome to the MongoDB shell. | ||
+ | For interactive help, type " | ||
+ | For more comprehensive documentation, | ||
+ | https:// | ||
+ | Questions? Try the MongoDB Developer Community Forums | ||
+ | https:// | ||
+ | Server has startup warnings: | ||
+ | 2023-08-19T13: | ||
+ | 2023-08-19T13: | ||
+ | 2023-08-19T13: | ||
+ | 2023-08-19T13: | ||
+ | 2023-08-19T13: | ||
+ | 2023-08-19T13: | ||
+ | 2023-08-19T13: | ||
+ | 2023-08-19T13: | ||
+ | 2023-08-19T13: | ||
+ | --- | ||
+ | Enable MongoDB' | ||
+ | metrics about your deployment (disk utilization, | ||
+ | |||
+ | The monitoring data will be available on a MongoDB website with a unique URL accessible to you | ||
+ | and anyone you share the URL with. MongoDB may use this information to make product | ||
+ | improvements and to suggest MongoDB products and deployment options to you. | ||
+ | |||
+ | To enable free monitoring, run the following command: db.enableFreeMonitoring() | ||
+ | To permanently disable this reminder, run the following command: db.disableFreeMonitoring() | ||
+ | --- | ||
+ | |||
+ | > | ||
+ | </ | ||
+ | |||
+ | Sortez de mongo et du conteneur : | ||
+ | |||
+ | < | ||
+ | > exit | ||
+ | bye | ||
+ | [root@b45b7b136f06 /]# exit | ||
+ | exit | ||
+ | root@debian11: | ||
+ | </ | ||
+ | |||
+ | ====1.22 - Utilisation de la commande docker commit==== | ||
+ | |||
+ | Créez maintenant une nouvelle image à partir de votre conteneur : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | b45b7b136f06 | ||
+ | 5bec576b4b69 | ||
+ | 37cb0af1e97f | ||
+ | d838ea83033e | ||
+ | |||
+ | root@debian11: | ||
+ | sha256: | ||
+ | |||
+ | root@debian11: | ||
+ | </ | ||
+ | |||
+ | Supprimez le conteneur utilisé pour créer l' | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | b45b | ||
+ | |||
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | 5bec576b4b69 | ||
+ | 37cb0af1e97f | ||
+ | d838ea83033e | ||
+ | </ | ||
+ | |||
+ | Utilisez la nouvelle image pour lancer un conteneur nommé **mongo** : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | |||
+ | [root@0c597fe7b628 /]# ls / | ||
+ | / | ||
+ | |||
+ | [root@0c597fe7b628 /]# ps aux | ||
+ | USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | ||
+ | root | ||
+ | root 18 0.0 0.0 47604 3696 pts/0 R+ | ||
+ | </ | ||
+ | |||
+ | Editez le fichier /etc/bashrc : | ||
+ | |||
+ | < | ||
+ | [root@0c597fe7b628 /]# echo "/ | ||
+ | |||
+ | [root@0c597fe7b628 /]# tail /etc/bashrc | ||
+ | fi | ||
+ | done | ||
+ | |||
+ | unset i | ||
+ | unset -f pathmunge | ||
+ | fi | ||
+ | |||
+ | fi | ||
+ | # vim: | ||
+ | / | ||
+ | |||
+ | [root@0c597fe7b628 /]# | ||
+ | </ | ||
+ | |||
+ | Consultez la liste des conteneurs et relevez le CONTAINER ID du conteneur **mongo** : | ||
+ | |||
+ | < | ||
+ | [root@0c597fe7b628 /]# exit | ||
+ | exit | ||
+ | |||
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | 0c597fe7b628 | ||
+ | 5bec576b4b69 | ||
+ | 37cb0af1e97f | ||
+ | d838ea83033e | ||
+ | |||
+ | root@debian11: | ||
+ | </ | ||
+ | |||
+ | Utilisez la commande commit pour " | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | sha256: | ||
+ | </ | ||
+ | |||
+ | Démarrez de nouveau le conteneur pour vérifier que mongod fonctionne : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | 0c59 | ||
+ | |||
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | 5bec576b4b69 | ||
+ | 37cb0af1e97f | ||
+ | d838ea83033e | ||
+ | |||
+ | root@debian11: | ||
+ | about to fork child process, waiting until server is ready for connections. | ||
+ | forked process: 19 | ||
+ | [root@4e8fc8b07afe /]# child process started successfully, | ||
+ | [Enter] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
+ | [1]+ Done / | ||
+ | |||
+ | [root@4e8fc8b07afe /]# ps aux | ||
+ | USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | ||
+ | root | ||
+ | root 19 3.5 0.6 1534072 105260 ? Sl | ||
+ | root 56 0.0 0.0 47604 3672 pts/0 R+ | ||
+ | |||
+ | [root@4e8fc8b07afe /]# | ||
+ | </ | ||
+ | |||
+ | ====1.23 - Se connecter au serveur du conteneur de l' | ||
+ | |||
+ | Pour pouvoir se connecter à mongodb depuis la machine hôte, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@4e8fc8b07afe /]# vi / | ||
+ | |||
+ | [root@4e8fc8b07afe /]# cat / | ||
+ | bindIp: 0.0.0.0 | ||
+ | </ | ||
+ | |||
+ | Sortez du conteneur, re-créez une image, supprimez le conteneur utilisé et relancez de nouveau le conteneur : | ||
+ | |||
+ | < | ||
+ | [root@4e8fc8b07afe /]# exit | ||
+ | exit | ||
+ | |||
+ | root@debian11: | ||
+ | sha256: | ||
+ | |||
+ | root@debian11: | ||
+ | mongo | ||
+ | |||
+ | root@debian11: | ||
+ | about to fork child process, waiting until server is ready for connections. | ||
+ | forked process: 19 | ||
+ | [root@e2ace1b2a6a2 /]# child process started successfully, | ||
+ | [Enter] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
+ | [1]+ Done / | ||
+ | |||
+ | [root@e2ace1b2a6a2 /]# | ||
+ | </ | ||
+ | |||
+ | Dans votre machine hôte, configurez le dépôt de mongodb : | ||
+ | |||
+ | < | ||
+ | [root@e2ace1b2a6a2 /]# exit | ||
+ | exit | ||
+ | root@debian11: | ||
+ | |||
+ | root@debian11: | ||
+ | Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)). | ||
+ | Executing: / | ||
+ | gpg: key 68818C72E52529D4: | ||
+ | gpg: Total number processed: 1 | ||
+ | gpg: | ||
+ | |||
+ | root@debian11: | ||
+ | deb [trusted=yes] http:// | ||
+ | |||
+ | root@debian11: | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | Cette fois, installez uniquement le client de mongodb : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | Reading package lists... Done | ||
+ | Building dependency tree... Done | ||
+ | Reading state information... Done | ||
+ | The following packages were automatically installed and are no longer required: | ||
+ | libopengl0 linux-headers-5.10.0-15-amd64 linux-headers-5.10.0-15-common | ||
+ | Use 'apt autoremove' | ||
+ | The following NEW packages will be installed: | ||
+ | mongodb-org-shell | ||
+ | 0 upgraded, 1 newly installed, 0 to remove and 5 not upgraded. | ||
+ | Need to get 9,970 kB of archives. | ||
+ | After this operation, 40.3 MB of additional disk space will be used. | ||
+ | Get:1 http:// | ||
+ | Fetched 9,970 kB in 1s (10.8 MB/s) | ||
+ | Selecting previously unselected package mongodb-org-shell. | ||
+ | (Reading database ... 166761 files and directories currently installed.) | ||
+ | Preparing to unpack .../ | ||
+ | Unpacking mongodb-org-shell (4.0.28) ... | ||
+ | Setting up mongodb-org-shell (4.0.28) ... | ||
+ | Processing triggers for man-db (2.9.4-2) ... | ||
+ | </ | ||
+ | |||
+ | Notez qu'à ce stade le conteneur ne possède pas d' | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | </ | ||
+ | |||
+ | Démarrez donc le conteneur et cherchez l' | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | mongo | ||
+ | |||
+ | root@debian11: | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | |||
+ | root@debian11: | ||
+ | </ | ||
+ | |||
+ | Connectez-vous maintenant à votre mongodb à partir de la machine hôte : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | MongoDB shell version v4.0.28 | ||
+ | connecting to: mongodb:// | ||
+ | Implicit session: session { " | ||
+ | MongoDB server version: 4.2.24 | ||
+ | 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: | ||
+ | 2023-08-19T14: | ||
+ | 2023-08-19T14: | ||
+ | 2023-08-19T14: | ||
+ | 2023-08-19T14: | ||
+ | 2023-08-19T14: | ||
+ | 2023-08-19T14: | ||
+ | 2023-08-19T14: | ||
+ | 2023-08-19T14: | ||
+ | 2023-08-19T14: | ||
+ | --- | ||
+ | Enable MongoDB' | ||
+ | metrics about your deployment (disk utilization, | ||
+ | |||
+ | The monitoring data will be available on a MongoDB website with a unique URL accessible to you | ||
+ | and anyone you share the URL with. MongoDB may use this information to make product | ||
+ | improvements and to suggest MongoDB products and deployment options to you. | ||
+ | |||
+ | To enable free monitoring, run the following command: db.enableFreeMonitoring() | ||
+ | To permanently disable this reminder, run the following command: db.disableFreeMonitoring() | ||
+ | --- | ||
+ | |||
+ | > exit | ||
+ | bye | ||
+ | root@debian11: | ||
+ | </ | ||
+ | |||
+ | ----- | ||
+ | |||
+ | Copyright © 2024 Hugh Norris. | ||