Différences

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

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
elearning:workbooks:docker1:drf01 [2020/06/26 11:40] adminelearning:workbooks:docker1:drf01 [2022/12/15 16:44] (Version actuelle) admin
Ligne 1: Ligne 1:
 ~~PDF:LANDSCAPE~~ ~~PDF:LANDSCAPE~~
  
-Version : **2020.01**+Version : **2022.01**
  
 Dernière mise-à-jour : ~~LASTMOD~~ Dernière mise-à-jour : ~~LASTMOD~~
  
-======DOF102 - Gérer les Images Docker======+======DOF102 - Démarrer avec Docker======
  
 =====Contenu du Module===== =====Contenu du Module=====
  
-  * **DOF102 - Gérer et Stocker les Images Docker** +  * **DOF102 - Démarrer avec Docker** 
-    * LAB #4 - Re-créer une image officielle docker +    * Contenu du Module 
-      * Utilisation d'un Dockerfile +    * Présentation de Docker 
-      * FROM +    * LAB #1 - Travailler avec Docker 
-      * RUN +      * 1.1 - Installer docker 
-      * ENV +      * 1.2 - Démarrer un Conteneur 
-      * VOLUME +      * 1.3 - Consulter la Liste des Conteneurs et Images 
-      * COPY +      * 1.4 - Rechercher une Image dans un Dépôt 
-      * ENTRYPOINT +      * 1.5 Supprimer un Conteneur d'une Image 
-      * EXPOSE +      * 1.6 - Créer une Image à partir d'un Conteneur Modifié 
-      * CMD +      * 1.7 - Supprimer une Image 
-      * Autres Commandes +      * 1.8 - Créer un Conteneur avec un Nom Spécifique 
-    LAB #5 Créer un Dockerfile +      * 1.9 - Exécuter une Commande dans un Conteneur 
-      * Création et test du script +      * 1.10 - Injecter des Variables d'Environnement dans un Conteneur 
-      * Bonnes Pratiques liées au Cache+      * 1.11 - Modifier le Nom d'Hôte d'un Conteneur 
 +      * 1.12 - Mapper des Ports d'un Conteneur 
 +      * 1.13 - Démarrer un Conteneur en mode Détaché 
 +      * 1.14 - Accéder aux Services d'un Conteneur de l'Extérieur 
 +      * 1.15 - Arrêter et Démarrer un Conteneur 
 +      1.16 Utiliser des Signaux avec un Conteneur 
 +      * 1.17 - Forcer la Suppression d'un Conteneur en cours d'Exécution 
 +      * 1.18 - Utilisation Simple d'un Volume 
 +      * 1.19 - Télécharger une image sans créer un conteneur 
 +      * 1.20 - S'attacher à un conteneur en cours d'exécution 
 +      * 1.21 - Installer un logiciel dans le conteneur 
 +      * 1.22 - Utilisation de la commande docker commit 
 +      * 1.23 - Se connecter au serveur du conteneur de l'extérieur
  
-=====LAB #4 - Re-créer une image officielle docker=====+=====Présentation de Docker=====
  
-====Utilisation d'un Dockerfile====+La virtualisation classique nécessite l'utilisation d'un hyperviseur :
  
-Bien que la compilation des images soient assuré par Docker Hub, il est tout à fait possible de compiler une image "officielle" à partir d'un Dockerfile :+{{ :elearning:workbooks:docker3:751px-container-vm-whatcontainer_2.png?nolink&600 |}}
  
-<code> +Docker est une application de virtualisation légère qui utilise des **images** et des **conteneurs**.
-root@debian9:~# mkdir mongodb +
-root@debian9:~# cd mongodb/ +
-root@debian9:~/mongodb# touch Dockerfile docker-entrypoint.sh +
-</code>+
  
-Le Docker file contient les instructions nécessaires pour la contruction de l'image :+Une **image** est un paquet exécutable contenant tout ce qu'il est nécessaire afin d'exécuter un logiciel donné, incluant :
  
-<file txt Dockerfile> +  * le code 
-FROM ubuntu:bionic+  * un runtime 
 +  * des bibliothèques, 
 +  * des variables d'environnement 
 +  * des fichiers de configuration
  
-# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added +Un **conteneur** est une instance de l'image en cours d'exécution en mémoire. Elle est isolée de l'environnement de l'hôte par défaut mais peut accéder à des fichiers et de ports de l'hôte selon la configuration.
-RUN groupadd -r mongodb && useradd -r -g mongodb mongodb+
  
-RUN set -eux; \ +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.
- apt-get update; \ +
- apt-get install -y --no-install-recommends \ +
- ca-certificates \ +
- jq \ +
- numactl \ +
- ; \ +
- if ! command -v ps > /dev/null; then \ +
- apt-get install -y --no-install-recommends procps; \ +
- fi; \ +
- rm -rf /var/lib/apt/lists/*+
  
-# grab gosu for easy step-down from root (https://github.com/tianon/gosu/releases) +{{ :elearning:workbooks:docker3:docker-container-architecture.png?nolink&600 |}}
-ENV GOSU_VERSION 1.11 +
-# grab "js-yaml" for parsing mongod's YAML config files (https://github.com/nodeca/js-yaml/releases) +
-ENV JSYAML_VERSION 3.13.0+
  
-RUN set -ex; \ +Docker existe en deux versions **Docker-CE** (Docker Community Editionet **Docker-EE** (Docker Enterprise Edition). Pour consulter les différences entre les deux versions, consultez le lien  **[[https://docs.docker.com/engine/installation/]]**.
-+
- apt-get update; \ +
- apt-get install -y --no-install-recommends \ +
- wget \ +
- ; \ +
- if ! command -v gpg > /dev/null; then \ +
- apt-get install -y --no-install-recommends gnupg dirmngr; \ +
- fi; \ +
- rm -rf /var/lib/apt/lists/*; \ +
-+
- dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \ +
- wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch";+
- wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc";+
- export GNUPGHOME="$(mktemp -d)"; \ +
- gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4;+
- gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu;+
- command -v gpgconf && gpgconf --kill all || :; \ +
- rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc; \ +
- chmod +x /usr/local/bin/gosu;+
- gosu --version; \ +
- gosu nobody true; \ +
-+
- wget -O /js-yaml.js "https://github.com/nodeca/js-yaml/raw/${JSYAML_VERSION}/dist/js-yaml.js"; \ +
-# TODO some sort of download verification here +
-+
- apt-get purge -y --auto-remove wget+
  
-RUN mkdir /docker-entrypoint-initdb.d+Pour gérer le système de fichiers du conteneur, Docker utilisait au départ le filesystem AUFSAUFS 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 **/var/lib/docker/aufs** :
  
-ENV GPG_KEYS E162F504A20CDF15827F718D4B7C549A058F8B6B +{{ :elearning:workbooks:docker3:aufs_layers.jpg?nolink&600 |}}
-RUN set -ex; \ +
- export GNUPGHOME="$(mktemp -d)"; \ +
- for key in $GPG_KEYS; do \ +
- gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key";+
- done; \ +
- gpg --batch --export $GPG_KEYS > /etc/apt/trusted.gpg.d/mongodb.gpg;+
- command -v gpgconf && gpgconf --kill all || :; \ +
- rm -r "$GNUPGHOME";+
- apt-key list+
  
-# Allow build-time overrides (egto build image with MongoDB Enterprise version) +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'image contiennent le même objet, le conteneur "gagne" et cache l'objet dans l'image :
-# Options for MONGO_PACKAGE: mongodb-org OR mongodb-enterprise +
-# Options for MONGO_REPO: repo.mongodb.org OR repo.mongodb.com +
-# Exampledocker build --build-arg MONGO_PACKAGE=mongodb-enterprise --build-arg MONGO_REPO=repo.mongodb.com . +
-ARG MONGO_PACKAGE=mongodb-org-unstable +
-ARG MONGO_REPO=repo.mongodb.org +
-ENV MONGO_PACKAGE=${MONGO_PACKAGE} MONGO_REPO=${MONGO_REPO}+
  
-ENV MONGO_MAJOR 4.1 +{{ :elearning:workbooks:docker3:overlay_constructs.jpg?nolink&600 |Image 2}}
-ENV MONGO_VERSION 4.1.9 +
-# bashbrew-architectures:amd64 arm64v8 s390x +
-RUN echo "deb http://$MONGO_REPO/apt/ubuntu bionic/${MONGO_PACKAGE%-unstable}/$MONGO_MAJOR multiverse" tee "/etc/apt/sources.list.d/${MONGO_PACKAGE%-unstable}.list"+
  
-RUN set -x \ +Le système de fichiers OverlayFS ne sait gérer que deux niveaux. Ceci implique une utilisation excessive d'inodes dans la cas d'une image à de niveaux multiples car chaque image doit résider dans son propre repertoire qui se situe dans **/var/lib/docker/overlay**. Des liens physiques sont ensuite utilisés pour référencer des données dans les niveaux inférieurs.
- && apt-get update \ +
- && apt-get install -y \ +
- ${MONGO_PACKAGE}=$MONGO_VERSION \ +
- ${MONGO_PACKAGE}-server=$MONGO_VERSION \ +
- ${MONGO_PACKAGE}-shell=$MONGO_VERSION \ +
- ${MONGO_PACKAGE}-mongos=$MONGO_VERSION \ +
- ${MONGO_PACKAGE}-tools=$MONGO_VERSION \ +
- && rm -rf /var/lib/apt/lists/* +
- && rm -rf /var/lib/mongodb \ +
- && mv /etc/mongod.conf /etc/mongod.conf.orig+
  
-RUN mkdir -p /data/db /data/configdb \ +Cette limitation a donné lieu à l'introduction du système de fichiers **Overlay2** actuellement utilisé par Docker. Overlay2 est capable de gérer 128 layers.
- && chown -R mongodb:mongodb /data/db /data/configdb +
-VOLUME /data/db /data/configdb+
  
-COPY docker-entrypoint.sh /usr/local/bin/ +=====LAB #1 Travailler avec Docker=====
-ENTRYPOINT ["docker-entrypoint.sh"]+
  
-EXPOSE 27017 +====1.1 - Installer docker====
-CMD ["mongod"+
-</file>+
  
-Le fichier docker-entrypoint.sh sert à lancer le serveur mongodb dans le conteneur :+Docker n'est pas dans le dépôts de Debian. Afin de l'installer il convient d'ajouter le dépôt de docker. Premièrement, il est nécessaire d'installer les paquets permettant à Debian d'utiliser un dépôt en https :
  
-<file txt docker-entrypoint.sh> +<code> 
-#!/bin/bash +root@debian9:~# apt-get update 
-set -Eeuo pipefail+..
 +root@debian9:~apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common 
 +Reading package lists... Done 
 +Building dependency tree        
 +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: 
 +  libcurl3 python3-dbus python3-software-properties unattended-upgrades 
 +Suggested packages: 
 +  python-dbus-doc python3-dbus-dbg 
 +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]  
 +</code>
  
-if [ "${1:0:1}" = '-' ]; then +Téléchargez la clef GPG officielle de docker :
- set -- mongod "$@" +
-fi+
  
-originalArgOne="$1"+<code> 
 +root@debian9:~# curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - 
 +OK 
 +</code>
  
-# allow the container to be started with `--user` +Vérifiez que l'ID de la clef est **9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88** :
-# all mongocommands should be dropped to the correct user +
-if [[ "$originalArgOne" == mongo]] && [ "$(id -u)" = '0' ]; then +
- if [ "$originalArgOne" = 'mongod' ]; then +
- find /data/configdb /data/db \! -user mongodb -exec chown mongodb '{}'+
- fi+
  
- # make sure we can write to stdout and stderr as "mongodb" +<code> 
-(for our "initdb" code later; see "--logpath" below) +root@debian9:~apt-key fingerprint 0EBFCD88 
- chown --dereference mongodb "/proc/$$/fd/1" "/proc/$$/fd/2" || : +/etc/apt/trusted.gpg 
- # ignore errors thanks to https://github.com/docker-library/mongo/issues/149+-------------------- 
 +pub   4096R/0EBFCD88 2017-02-22 
 +      Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88 
 +uid                  Docker Release (CE deb) <docker@docker.com
 +sub   4096R/F273FCD8 2017-02-22 
 +... 
 +</code>
  
- exec gosu mongodb "$BASH_SOURCE" "$@" +Ajoutez le dépôt **stable** de docker :
-fi+
  
-# you should use numactl to start your mongod instances, including the config servers, mongos instances, and any clients. +<code> 
-# https://docs.mongodb.com/manual/administration/production-notes/#configuring-numa-on-linux +root@debian9:~add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable
-if [[ "$originalArgOne" == mongo* ]]; then +</code>
- numa='numactl --interleave=all' +
- if $numa true &/dev/null; then +
- set -- $numa "$@" +
- fi +
-fi+
  
-# usage: file_env VAR [DEFAULT] +<WRAP center round important
-#    ie: file_env 'XYZ_DB_PASSWORD' 'example' +**Important** Notez que la commande **lsb_release -cs** retourne le nom de la distribution Debian, à savoir dans ce cas **stretch**. 
-# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of +</WRAP>
-#  "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) +
-file_env() { +
- local var="$1" +
- local fileVar="${var}_FILE" +
- local def="${2:-}" +
- if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then +
- echo >&2 "error: both $var and $fileVar are set (but are exclusive)" +
- exit 1 +
- fi +
- local val="$def" +
- if [ "${!var:-}" ]; then +
- val="${!var}" +
- elif [ "${!fileVar:-}" ]; then +
- val="$("${!fileVar}")" +
- fi +
- export "$var"="$val" +
- unset "$fileVar" +
-}+
  
-# see https://github.com/docker-library/mongo/issues/147 (mongod is picky about duplicated arguments) +Installez maintenant le paquet **docker-ce** :
-_mongod_hack_have_arg() { +
- local checkArg="$1"; shift +
- local arg +
- for arg; do +
- case "$arg" in +
- "$checkArg"|"$checkArg"=*+
- return 0 +
- ;; +
- esac +
- done +
- return 1 +
-+
-# _mongod_hack_get_arg_val '--some-arg' "$@" +
-_mongod_hack_get_arg_val() { +
- local checkArg="$1"; shift +
- while [ "$#" -gt 0 ]; do +
- local arg="$1"; shift +
- case "$arg" in +
- "$checkArg"+
- echo "$1" +
- return 0 +
- ;; +
- "$checkArg"=*+
- echo "${arg#$checkArg=}" +
- return 0 +
- ;; +
- esac +
- done +
- return 1 +
-+
-declare -a mongodHackedArgs +
-# _mongod_hack_ensure_arg '--some-arg' "$@" +
-# set -- "${mongodHackedArgs[@]}" +
-_mongod_hack_ensure_arg() { +
- local ensureArg="$1"; shift +
- mongodHackedArgs=( "$@"+
- if ! _mongod_hack_have_arg "$ensureArg" "$@"; then +
- mongodHackedArgs+=( "$ensureArg"+
- fi +
-+
-# _mongod_hack_ensure_no_arg '--some-unwanted-arg' "$@" +
-# set -- "${mongodHackedArgs[@]}" +
-_mongod_hack_ensure_no_arg() { +
- local ensureNoArg="$1"; shift +
- mongodHackedArgs=() +
- while [ "$#" -gt 0 ]; do +
- local arg="$1"; shift +
- if [ "$arg" = "$ensureNoArg" ]; then +
- continue +
- fi +
- mongodHackedArgs+=( "$arg"+
- done +
-+
-# _mongod_hack_ensure_no_arg '--some-unwanted-arg' "$@" +
-# set -- "${mongodHackedArgs[@]}" +
-_mongod_hack_ensure_no_arg_val() { +
- local ensureNoArg="$1"; shift +
- mongodHackedArgs=() +
- while [ "$#" -gt 0 ]; do +
- local arg="$1"; shift +
- case "$arg" in +
- "$ensureNoArg"+
- shift # also skip the value +
- continue +
- ;; +
- "$ensureNoArg"=*) +
- # value is already included +
- continue +
- ;; +
- esac +
- mongodHackedArgs+=( "$arg"+
- done +
-+
-# _mongod_hack_ensure_arg_val '--some-arg' 'some-val' "$@" +
-# set -- "${mongodHackedArgs[@]}" +
-_mongod_hack_ensure_arg_val() { +
- local ensureArg="$1"; shift +
- local ensureVal="$1"; shift +
- _mongod_hack_ensure_no_arg_val "$ensureArg" "$@" +
- mongodHackedArgs+=( "$ensureArg" "$ensureVal"+
-}+
  
-_js_escape 'some "string" value' +<code> 
-_js_escape() { +root@debian9:~apt-get update 
- jq --null-input --arg 'str' "$1" '$str' +... 
-}+root@debian9:~# apt-get install docker-ce 
 +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]  
 +</code>
  
-jsonConfigFile="${TMPDIR:-/tmp}/docker-entrypoint-config.json" +Dernièrement, vérifiez la version de Docker client et serveur :
-tempConfigFile="${TMPDIR:-/tmp}/docker-entrypoint-temp-config.json" +
-_parse_config() { +
- if [ -s "$tempConfigFile" ]; then +
- return 0 +
- fi+
  
- local configPath +<code> 
- if configPath="$(_mongod_hack_get_arg_val --config "$@")"; then +root@debian9:~docker version 
- if --config is specified, parse it into a JSON file so we can remove a few problematic keys (especially SSL-related keys) +Client: Docker Engine Community 
- # see https://docs.mongodb.com/manual/reference/configuration-options/ + Version          19.03.4 
- mongo --norc --nodb --quiet --eval "load('/js-yaml.js'); printjson(jsyaml.load(cat($(_js_escape "$configPath"))))" > "$jsonConfigFile" + API version:       1.40 
- jq 'del(.systemLog, .processManagement, .net, .security)' "$jsonConfigFile" > "$tempConfigFile" + Go version:        go1.12.10 
- return 0 + Git commit:        9013bf583a 
- fi+ Built:             Fri Oct 18 15:52:34 2019 
 + OS/Arch:           linux/amd64 
 + Experimental:      false
  
- return 1 +Server: Docker Engine - Community 
-} + Engine: 
-dbPath= +  Version:          19.03.4 
-_dbPath() { +  API version:      1.40 (minimum version 1.12
- if [ -n "$dbPath" ]; then +  Go version:       go1.12.10 
- echo "$dbPath" +  Git commit:       9013bf583a 
- return +  Built:            Fri Oct 18 15:51:05 2019 
- fi+  OS/Arch:          linux/amd64 
 +  Experimental:     false 
 + containerd: 
 +  Version:          1.2.10 
 +  GitCommit:        b34a5c8af56e510852c35414db4c1f4fa6172339 
 + runc: 
 +  Version:          1.0.0-rc8+dev 
 +  GitCommit:        3e425f80a8c931f88e6d94a8c831b9d5aa481657 
 + docker-init: 
 +  Version:          0.18.0 
 +  GitCommit:        fec3683 
 +</code>
  
- if ! dbPath="$(_mongod_hack_get_arg_val --dbpath "$@")"; then +Docker est composé de trois éléments : un serveur, un client et un ou plusieur Repositories ou Dépôts :
- if _parse_config "$@"; then +
- dbPath="$(jq -r '.storage.dbPath // empty' "$jsonConfigFile")" +
- fi +
- fi+
  
- if [ -z "$dbPath" ]; then +{{ :elearning:workbooks:docker3:architecture.png?nolink&600 |}}
- if _mongod_hack_have_arg --configsvr "$@" || { +
- _parse_config "$@"+
- && clusterRole="$(jq -r '.sharding.clusterRole // empty' "$jsonConfigFile")"+
- && [ "$clusterRole" = 'configsvr'+
- }; then +
- # if running as config server, then the default dbpath is /data/configdb +
- # https://docs.mongodb.com/manual/reference/program/mongod/#cmdoption-mongod-configsvr +
- dbPath=/data/configdb +
- fi +
- fi+
  
- : "${dbPath:=/data/db}"+====1.2 - Démarrer un Conteneur====
  
- echo "$dbPath" +Démarrez un conteneur de l'image hello-world :
-}+
  
-if [ "$originalArgOne" = 'mongod' ]; then +<code> 
- file_env 'MONGO_INITDB_ROOT_USERNAME' +root@debian9:~docker run hello-world 
- file_env 'MONGO_INITDB_ROOT_PASSWORD' +Unable to find image 'hello-world:latestlocally 
-pre-check a few factors to see if it's even worth bothering with initdb +latest: Pulling from library/hello-world 
- shouldPerformInitdb= +1b930d010525: Pull complete  
- if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then +Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535 
- # if we have a username/password, let's set "--auth" +Status: Downloaded newer image for hello-world:latest
- _mongod_hack_ensure_arg '--auth' "$@" +
- set -- "${mongodHackedArgs[@]}" +
- shouldPerformInitdb='true' +
- elif [ "$MONGO_INITDB_ROOT_USERNAME" ] || [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then +
- cat >&2 <<-'EOF' +
- errormissing 'MONGO_INITDB_ROOT_USERNAME' or 'MONGO_INITDB_ROOT_PASSWORD' +
-        both must be specified for a user to be created +
- EOF +
- exit 1 +
- fi+
  
- if [ -z "$shouldPerformInitdb" ]; then +Hello from Docker! 
- # if we've got any /docker-entrypoint-initdb.d/* files to parse later, we should initdb +This message shows that your installation appears to be working correctly.
- for f in /docker-entrypoint-initdb.d/*; do +
- case "$f" in +
- *.sh|*.js) # this should match the set of files we check for below +
- shouldPerformInitdb="$f" +
- break +
- ;; +
- esac +
- done +
- fi+
  
- # check for a few known paths (to determine whether we've already initialized and should thus skip our initdb scripts) +To generate this message, Docker took the following steps: 
- if [ -"$shouldPerformInitdb" ]; then + 1. The Docker client contacted the Docker daemon. 
- dbPath="$(_dbPath "$@")" + 2. The Docker daemon pulled the "hello-worldimage from the Docker Hub. 
- for path in \ +    (amd64
- "$dbPath/WiredTiger" \ + 3. The Docker daemon created a new container from that image which runs the 
- "$dbPath/journal"+    executable that produces the output you are currently reading. 
- "$dbPath/local.0" \ + 4The Docker daemon streamed that output to the Docker client, which sent it 
- "$dbPath/storage.bson" \ +    to your terminal.
- ; do +
- if [ -e "$path" ]; then +
- shouldPerformInitdb= +
- break +
- fi +
- done +
- fi+
  
- if [ -n "$shouldPerformInitdb" ]; then +To try something more ambitious, you can run an Ubuntu container with: 
- mongodHackedArgs=( "$@" ) + docker run -it ubuntu bash
- if _parse_config "$@"; then +
- _mongod_hack_ensure_arg_val --config "$tempConfigFile" "${mongodHackedArgs[@]}" +
- fi +
- _mongod_hack_ensure_arg_val --bind_ip 127.0.0.1 "${mongodHackedArgs[@]}" +
- _mongod_hack_ensure_arg_val --port 27017 "${mongodHackedArgs[@]}" +
- _mongod_hack_ensure_no_arg --bind_ip_all "${mongodHackedArgs[@]}"+
  
- # remove "--auth" and "--replSet" for our initial startup (see https://docs.mongodb.com/manual/tutorial/enable-authentication/#start-mongodb-without-access-control) +Share images, automate workflows, and more with a free Docker ID
- https://github.com/docker-library/mongo/issues/211 + https://hub.docker.com/
- _mongod_hack_ensure_no_arg --auth "${mongodHackedArgs[@]}" +
- if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then +
- _mongod_hack_ensure_no_arg_val --replSet "${mongodHackedArgs[@]}" +
- fi+
  
- sslMode="$(_mongod_hack_have_arg '--sslPEMKeyFile' "$@" && echo 'allowSSL' || echo 'disabled')" # "BadValueneed sslPEMKeyFile when SSL is enabled" vs "BadValueneed to enable SSL via the sslMode flag when using SSL configuration parameters" +For more examples and ideas, visit: 
- _mongod_hack_ensure_arg_val --sslMode "$sslMode" "${mongodHackedArgs[@]}"+ https://docs.docker.com/get-started/ 
 +</code>
  
- if stat "/proc/$$/fd/1" /dev/null && [ -w "/proc/$$/fd/1" ]; then +<WRAP center round important
- # https://github.com/mongodb/mongo/blob/38c0eb538d0fd390c6cb9ce9ae9894153f6e8ef5/src/mongo/db/initialize_server_global_state.cpp#L237-L251 +**Important** Notez que si l'image servant à générer le conteneur n'est pas présente sur le système hôte, celle-ci est téléchargée automatiquement depuis un dépôt par défaut le dépôt **docker.io** en utilisant la commande **docker pull**
- # https://github.com/docker-library/mongo/issues/164#issuecomment-293965668 +</WRAP>
- _mongod_hack_ensure_arg_val --logpath "/proc/$$/fd/1" "${mongodHackedArgs[@]}" +
- else +
- initdbLogPath="$(_dbPath "$@")/docker-initdb.log" +
- echo >&2 "warning: initdb logs cannot write to '/proc/$$/fd/1', so they are in '$initdbLogPath' instead" +
- _mongod_hack_ensure_arg_val --logpath "$initdbLogPath" "${mongodHackedArgs[@]}" +
- fi +
- _mongod_hack_ensure_arg --logappend "${mongodHackedArgs[@]}"+
  
- pidfile="${TMPDIR:-/tmp}/docker-entrypoint-temp-mongod.pid" +Démarrez un conteneur de l'image ubuntu:latest en mode interactif grâce à l'utilisation des options **-i** et **-t** en lui passant en argument **bash** pour que celui-ci soient lancé au démarrage du conteneur :
- rm -f "$pidfile" +
- _mongod_hack_ensure_arg_val --pidfilepath "$pidfile" "${mongodHackedArgs[@]}"+
  
- "${mongodHackedArgs[@]}" --fork+<code> 
 +root@debian9:~# docker run -it ubuntu bash 
 +Unable to find image 'ubuntu:latest' locally 
 +latest: Pulling from library/ubuntu 
 +898c46f3b1a1: Pull complete  
 +63366dfa0a50: Pull complete  
 +041d4cd74a92: Pull complete  
 +6e1bee0f8701: Pull complete  
 +Digest: sha256:017eef0b616011647b269b5c65826e2e2ebddbe5d1f8c1e56b3599fb14fabec8 
 +Status: Downloaded newer image for ubuntu:latest 
 +root@3a3f9bda6cbd:/# ls 
 +bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var 
 +root@3a3f9bda6cbd:/# cat /etc/lsb-release 
 +DISTRIB_ID=Ubuntu 
 +DISTRIB_RELEASE=18.04 
 +DISTRIB_CODENAME=bionic 
 +DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS" 
 +</code>
  
- mongo=( mongo --host 127.0.0.1 --port 27017 --quiet )+<WRAP center round important> 
 +**Important** Notez que dans ce cas le conteneur est lancé avec comme argument **bash** qui lancera /bin/bash dans le conteneur. 
 +</WRAP>
  
- # check to see that our "mongod" actually did start up (catches "--help", "--version", MongoDB 3.2 being silly, slow prealloc, etc) +Consulter la liste des paquets installés dans le conteneur ubuntu :
- # https://jira.mongodb.org/browse/SERVER-16292 +
- tries=30 +
- while true; do +
- if ! { [ -s "$pidfile" ] && ps "$(< "$pidfile")" &> /dev/null; }; then +
- # bail ASAP if "mongod" isn't even running +
- echo >&+
- echo >&2 "error: $originalArgOne does not appear to have stayed running -- perhaps it had an error?" +
- echo >&+
- exit 1 +
- fi +
- if "${mongo[@]}" 'admin' --eval 'quit(0)' &> /dev/null; then +
- # success! +
- break +
- fi +
- (( tries-- )) +
- if [ "$tries" -le 0 ]; then +
- echo >&+
- echo >&2 "error$originalArgOne does not appear to have accepted connections quickly enough -- perhaps it had an error?" +
- echo >&+
- exit 1 +
- fi +
- sleep 1 +
- done+
  
- if "$MONGO_INITDB_ROOT_USERNAME" && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then +<code> 
- rootAuthDatabase='admin'+root@835001339e79:/# dpkg -l 
 +Desired=Unknown/Install/Remove/Purge/Hold 
 +| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend 
 +|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) 
 +||/ Name                                 Version                 Architecture            Description 
 ++++-====================================-=======================-=======================-============================================================================= 
 +ii  adduser                              3.116ubuntu1            all                     add and remove users and groups 
 +ii  apt                                  1.6.8                   amd64                   commandline package manager 
 +ii  base-files                           10.1ubuntu2.4           amd64                   Debian base system miscellaneous files 
 +ii  base-passwd                          3.5.44                  amd64                   Debian base system master password and group files 
 +ii  bash                                 4.4.18-2ubuntu1         amd64                   GNU Bourne Again SHell 
 +ii  bsdutils                             1:2.31.1-0.4ubuntu3.3   amd64                   basic utilities from 4.4BSD-Lite 
 +ii  bzip2                                1.0.6-8.1               amd64                   high-quality block-sorting file compressor - utilities 
 +ii  coreutils                            8.28-1ubuntu1           amd64                   GNU core utilities 
 +ii  dash                                 0.5.8-2.10              amd64                   POSIX-compliant shell 
 +ii  debconf                              1.5.66                  all                     Debian configuration management system 
 +ii  debianutils                          4.8.4                   amd64                   Miscellaneous utilities specific to Debian 
 +ii  diffutils                            1:3.6-1                 amd64                   File comparison utilities 
 +ii  dpkg                                 1.19.0.5ubuntu2.1       amd64                   Debian package management system 
 +ii  e2fsprogs                            1.44.1-1ubuntu1.1       amd64                   ext2/ext3/ext4 file system utilities 
 +ii  fdisk                                2.31.1-0.4ubuntu3.3     amd64                   collection of partitioning utilities 
 +ii  findutils                            4.6.0+git+20170828-2    amd64                   utilities for finding files--find, xargs 
 +ii  gcc-8-base:amd64                     8.2.0-1ubuntu2~18.04    amd64                   GCC, the GNU Compiler Collection (base package) 
 +ii  gpgv                                 2.2.4-1ubuntu1.2        amd64                   GNU privacy guard - signature verification tool 
 +ii  grep                                 3.1-2                   amd64                   GNU grep, egrep and fgrep 
 +ii  gzip                                 1.6-5ubuntu1            amd64                   GNU compression utilities 
 +ii  hostname                             3.20                    amd64                   utility to set/show the host name or domain name 
 +ii  init-system-helpers                  1.51                    all                     helper tools for all init systems 
 +ii  libacl1:amd64                        2.2.52-3build1          amd64                   Access control list shared library 
 +ii  libapt-pkg5.0:amd64                  1.6.8                   amd64                   package management runtime library 
 +ii  libattr1:amd64                       1:2.4.47-2build1        amd64                   Extended attribute shared library 
 +ii  libaudit-common                      1:2.8.2-1ubuntu1        all                     Dynamic library for security auditing - common files 
 +ii  libaudit1:amd64                      1:2.8.2-1ubuntu1        amd64                   Dynamic library for security auditing 
 +ii  libblkid1:amd64                      2.31.1-0.4ubuntu3.3     amd64                   block device ID library 
 +ii  libbz2-1.0:amd64                     1.0.6-8.1               amd64                   high-quality block-sorting file compressor library - runtime 
 +ii  libc-bin                             2.27-3ubuntu1           amd64                   GNU C Library: Binaries 
 +ii  libc6:amd64                          2.27-3ubuntu1           amd64                   GNU C Library: Shared libraries 
 +ii  libcap-ng0:amd64                     0.7.7-3.1               amd64                   An alternate POSIX capabilities library 
 +ii  libcom-err2:amd64                    1.44.1-1ubuntu1.1       amd64                   common error description library 
 +ii  libdb5.3:amd64                       5.3.28-13.1ubuntu1      amd64                   Berkeley v5.3 Database Libraries [runtime
 +ii  libdebconfclient0:amd64              0.213ubuntu1            amd64                   Debian Configuration Management System (C-implementation library) 
 +ii  libext2fs2:amd64                     1.44.1-1ubuntu1.1       amd64                   ext2/ext3/ext4 file system libraries 
 +ii  libfdisk1:amd64                      2.31.1-0.4ubuntu3.3     amd64                   fdisk partitioning library 
 +ii  libffi6:amd64                        3.2.1-8                 amd64                   Foreign Function Interface library runtime 
 +ii  libgcc1:amd64                        1:8.2.0-1ubuntu2~18.04  amd64                   GCC support library 
 +ii  libgcrypt20:amd64                    1.8.1-4ubuntu1.1        amd64                   LGPL Crypto library - runtime library 
 +ii  libgmp10:amd64                       2:6.1.2+dfsg-2          amd64                   Multiprecision arithmetic library 
 +ii  libgnutls30:amd64                    3.5.18-1ubuntu1         amd64                   GNU TLS library - main runtime library 
 +ii  libgpg-error0:amd64                  1.27-6                  amd64                   library for common error values and messages in GnuPG components 
 +ii  libhogweed4:amd64                    3.4-1                   amd64                   low level cryptographic library (public-key cryptos) 
 +ii  libidn2-0:amd64                      2.0.4-1.1build2         amd64                   Internationalized domain names (IDNA2008/TR46) library 
 +ii  liblz4-1:amd64                       0.0~r131-2ubuntu3       amd64                   Fast LZ compression algorithm library - runtime 
 +ii  liblzma5:amd64                       5.2.2-1.3               amd64                   XZ-format compression library 
 +ii  libmount1:amd64                      2.31.1-0.4ubuntu3.3     amd64                   device mounting library 
 +ii  libncurses5:amd64                    6.1-1ubuntu1.18.04      amd64                   shared libraries for terminal handling 
 +ii  libncursesw5:amd64                   6.1-1ubuntu1.18.04      amd64                   shared libraries for terminal handling (wide character support) 
 +ii  libnettle6:amd64                     3.4-1                   amd64                   low level cryptographic library (symmetric and one-way cryptos) 
 +ii  libp11-kit0:amd64                    0.23.9-2                amd64                   library for loading and coordinating access to PKCS#11 modules - runtime 
 +ii  libpam-modules:amd64                 1.1.8-3.6ubuntu2.18.04. amd64                   Pluggable Authentication Modules for PAM 
 +ii  libpam-modules-bin                   1.1.8-3.6ubuntu2.18.04. amd64                   Pluggable Authentication Modules for PAM - helper binaries 
 +ii  libpam-runtime                       1.1.8-3.6ubuntu2.18.04. all                     Runtime support for the PAM library 
 +ii  libpam0g:amd64                       1.1.8-3.6ubuntu2.18.04. amd64                   Pluggable Authentication Modules library 
 +ii  libpcre3:amd64                       2:8.39-9                amd64                   Old Perl 5 Compatible Regular Expression Library - runtime files 
 +ii  libprocps6:amd64                     2:3.3.12-3ubuntu1.1     amd64                   library for accessing process information from /proc 
 +ii  libseccomp2:amd64                    2.3.1-2.1ubuntu4        amd64                   high level interface to Linux seccomp filter 
 +ii  libselinux1:amd64                    2.7-2build2             amd64                   SELinux runtime shared libraries 
 +ii  libsemanage-common                   2.7-2build2             all                     Common files for SELinux policy management libraries 
 +ii  libsemanage1:amd64                   2.7-2build2             amd64                   SELinux policy management library 
 +ii  libsepol1:amd64                      2.7-1                   amd64                   SELinux library for manipulating binary security policies 
 +ii  libsmartcols1:amd64                  2.31.1-0.4ubuntu3.3     amd64                   smart column output alignment library 
 +ii  libss2:amd64                         1.44.1-1ubuntu1.1       amd64                   command-line interface parsing library 
 +ii  libstdc++6:amd64                     8.2.0-1ubuntu2~18.04    amd64                   GNU Standard C++ Library v3 
 +ii  libsystemd0:amd64                    237-3ubuntu10.13        amd64                   systemd utility library 
 +ii  libtasn1-6:amd64                     4.13-2                  amd64                   Manage ASN.1 structures (runtime) 
 +ii  libtinfo5:amd64                      6.1-1ubuntu1.18.04      amd64                   shared low-level terminfo library for terminal handling 
 +ii  libudev1:amd64                       237-3ubuntu10.13        amd64                   libudev shared library 
 +ii  libunistring2:amd64                  0.9.9-0ubuntu1          amd64                   Unicode string library for C 
 +ii  libuuid1:amd64                       2.31.1-0.4ubuntu3.3     amd64                   Universally Unique ID library 
 +ii  libzstd1:amd64                       1.3.3+dfsg-2ubuntu1     amd64                   fast lossless compression algorithm 
 +ii  login                                1:4.5-1ubuntu1          amd64                   system login tools 
 +ii  lsb-base                             9.20170808ubuntu1       all                     Linux Standard Base init script functionality 
 +ii  mawk                                 1.3.3-17ubuntu3         amd64                   a pattern scanning and text processing language 
 +ii  mount                                2.31.1-0.4ubuntu3.3     amd64                   tools for mounting and manipulating filesystems 
 +ii  ncurses-base                         6.1-1ubuntu1.18.04      all                     basic terminal type definitions 
 +ii  ncurses-bin                          6.1-1ubuntu1.18.04      amd64                   terminal-related programs and man pages 
 +ii  passwd                               1:4.5-1ubuntu1          amd64                   change and administer password and group data 
 +ii  perl-base                            5.26.1-6ubuntu0.3       amd64                   minimal Perl system 
 +ii  procps                               2:3.3.12-3ubuntu1.1     amd64                   /proc file system utilities 
 +ii  sed                                  4.4-2                   amd64                   GNU stream editor for filtering/transforming text 
 +ii  sensible-utils                       0.0.12                  all                     Utilities for sensible alternative selection 
 +ii  sysvinit-utils                       2.88dsf-59.10ubuntu1    amd64                   System-V-like utilities 
 +ii  tar                                  1.29b-2ubuntu0.1        amd64                   GNU version of the tar archiving utility 
 +ii  ubuntu-keyring                       2018.09.18.1~18.04.0    all                     GnuPG keys of the Ubuntu archive 
 +ii  util-linux                           2.31.1-0.4ubuntu3.3     amd64                   miscellaneous system utilities 
 +ii  zlib1g:amd64                         1:1.2.11.dfsg-0ubuntu2  amd64                   compression library - runtime 
 +root@835001339e79:/# exit 
 +exit 
 +root@debian9:~#  
 +</code>
  
- "${mongo[@]}" "$rootAuthDatabase" <<-EOJS +Les options de la commande docker run peuvent être visualisées avec la commande :
- db.createUser({ +
- user$(_js_escape "$MONGO_INITDB_ROOT_USERNAME"), +
- pwd: $(_js_escape "$MONGO_INITDB_ROOT_PASSWORD"), +
- roles: [ { role: 'root', db: $(_js_escape "$rootAuthDatabase") } ] +
- }) +
- EOJS +
- fi+
  
- export MONGO_INITDB_DATABASE="${MONGO_INITDB_DATABASE:-test}"+<code> 
 +root@debian9:~# docker run --help
  
- echo +Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
- for f in /docker-entrypoint-initdb.d/*; do +
- case "$f" in +
- *.sh) echo "$0: running $f"; "$f" ;; +
- *.js) echo "$0: running $f"; "${mongo[@]}" "$MONGO_INITDB_DATABASE" "$f"; echo ;; +
- *)    echo "$0: ignoring $f" ;; +
- esac +
- echo +
- done+
  
- "${mongodHackedArgs[@]}" --shutdown +Run a command in a new container
- rm -f "$pidfile"+
  
- echo +Options: 
- echo 'MongoDB init process complete; ready for start up.' +      --add-host list                  Add a custom host-to-IP mapping (host:ip) 
- echo +  -a, --attach list                    Attach to STDIN, STDOUT or STDERR 
- fi+      --blkio-weight uint16            Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0) 
 +      --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           Optional parent cgroup for the container 
 +      --cidfile string                 Write the container ID to the file 
 +      --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                   Number of CPUs 
 +      --cpuset-cpus string             CPUs in which to allow execution (0-3, 0,1) 
 +      --cpuset-mems string             MEMs in which to allow execution (0-3, 0,1) 
 +  -d, --detach                         Run container in background and print container ID 
 +      --detach-keys string             Override the key sequence for detaching a container 
 +      --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          Skip image verification (default true) 
 +      --dns list                       Set custom DNS servers 
 +      --dns-option list                Set DNS options 
 +      --dns-search list                Set custom DNS search domains 
 +      --entrypoint string              Overwrite the default ENTRYPOINT of the image 
 +  -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              Command to run to check health 
 +      --health-interval duration       Time between running the check (ms|s|m|h) (default 0s) 
 +      --health-retries int             Consecutive failures needed to report unhealthy 
 +      --health-start-period duration   Start period for the container to initialize before starting health-retries countdown (ms|s|m|h) (default 0s) 
 +      --health-timeout duration        Maximum time to allow one check to run (ms|s|m|h) (default 0s) 
 +      --help                           Print usage 
 +  -h, --hostname string                Container host name 
 +      --init                           Run an init inside the container that forwards signals and reaps processes 
 +  -i, --interactive                    Keep STDIN open even if not attached 
 +      --ip string                      IPv4 address (e.g., 172.30.100.104) 
 +      --ip6 string                     IPv6 address (e.g., 2001:db8::33) 
 +      --ipc string                     IPC mode to use 
 +      --isolation string               Container isolation technology 
 +      --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             Container IPv4/IPv6 link-local addresses 
 +      --log-driver string              Logging driver for the container 
 +      --log-opt list                   Log driver options 
 +      --mac-address string             Container MAC address (e.g., 92:d0:c6:0a:29:33) 
 +  -m, --memory bytes                   Memory limit 
 +      --memory-reservation bytes       Memory soft limit 
 +      --memory-swap bytes              Swap limit equal to memory plus swap: '-1' to enable unlimited swap 
 +      --memory-swappiness int          Tune container memory swappiness (0 to 100) (default -1) 
 +      --mount mount                    Attach a filesystem mount to the container 
 +      --name string                    Assign a name to the container 
 +      --network string                 Connect a container to a network (default "default"
 +      --network-alias list             Add network-scoped alias for the container 
 +      --no-healthcheck                 Disable any container-specified HEALTHCHECK 
 +      --oom-kill-disable               Disable OOM Killer 
 +      --oom-score-adj int              Tune host's OOM preferences (-1000 to 1000) 
 +      --pid string                     PID namespace to use 
 +      --pids-limit int                 Tune container pids limit (set -1 for unlimited) 
 +      --privileged                     Give extended privileges to this container 
 +  -p, --publish list                   Publish a container's port(s) to the host 
 +  -P, --publish-all                    Publish all exposed ports to random ports 
 +      --read-only                      Mount the container's root filesystem as read only 
 +      --restart string                 Restart policy to apply when a container exits (default "no"
 +      --rm                             Automatically remove the container when it exits 
 +      --runtime string                 Runtime to use for this container 
 +      --security-opt list              Security Options 
 +      --shm-size bytes                 Size of /dev/shm 
 +      --sig-proxy                      Proxy received signals to the process (default true) 
 +      --stop-signal string             Signal to stop a container (default "SIGTERM"
 +      --stop-timeout int               Timeout (in seconds) to stop a container 
 +      --storage-opt list               Storage driver options for the container 
 +      --sysctl map                     Sysctl options (default map[]) 
 +      --tmpfs list                     Mount a tmpfs directory 
 +  -t, --tty                            Allocate a pseudo-TTY 
 +      --ulimit ulimit                  Ulimit options (default []) 
 +  -u, --user string                    Username or UID (format: <name|uid>[:<group|gid>]) 
 +      --userns string                  User namespace to use 
 +      --uts string                     UTS namespace to use 
 +  -v, --volume list                    Bind mount a volume 
 +      --volume-driver string           Optional volume driver for the container 
 +      --volumes-from list              Mount volumes from the specified container(s) 
 +  -w, --workdir string                 Working directory inside the container 
 +</code>
  
- # MongoDB 3.6+ defaults to localhost-only binding +====1.3 Consulter la Liste des Conteneurs et Images====
- if mongod --help 2>&1 | grep -q -- --bind_ip_all; then # TODO remove this conditional when 3.4 is no longer supported +
- haveBindIp= +
- if _mongod_hack_have_arg --bind_ip "$@" || _mongod_hack_have_arg --bind_ip_all "$@"; then +
- haveBindIp=1 +
- elif _parse_config "$@" && jq --exit-status '.net.bindIp // .net.bindIpAll' "$jsonConfigFile" > /dev/null; then +
- haveBindIp=+
- fi +
- if [ -z "$haveBindIp" ]; then +
- # so if no "--bind_ip" is specified, let's add "--bind_ip_all" +
- set -- "$@" --bind_ip_all +
- fi +
- fi+
  
- unset "${!MONGO_INITDB_@}" +Pour consulter tous les conteneurs, utilisez la commande **docker ps** avec l'option **-a** :
-fi+
  
-rm -"$jsonConfigFile" "$tempConfigFile"+<code> 
 +root@debian9:~# docker ps -
 +CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS                       PORTS               NAMES 
 +3a3f9bda6cbd        ubuntu              "bash             About a minute ago   Exited (127) 3 seconds ago                       wizardly_buck 
 +26ef17bd115d        hello-world         "/hello           8 minutes ago        Exited (0) 8 minutes ago                         angry_chaplygin 
 +</code>
  
-exec "$@" +<WRAP center round important> 
-</file>+**Important** - Notez que chaque conteneur peut être référencé par son **CONTAINER ID** ou par son **NAME**. 
 +</WRAP>
  
-Examinons chaque commande dans le Dockerfile :+Pour consulter la liste des images, utilisez la commande **docker images** :
  
-====FROM====+<code> 
 +root@debian9:~# docker images 
 +REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE 
 +ubuntu              latest              94e814e2efa8        4 weeks ago         88.9MB 
 +hello-world         latest              fce289e99eb9        3 months ago        4.84kB 
 +</code>
  
-<file+<WRAP center round important
-FROM ubuntu:bionic +**Important** - Notez que chaque image est référencée par son IMAGE ID. 
-</file>+</WRAP>
  
-Cette ligne définit l'image à partir de laquelle sera construite notre imageQuand l'image n'est construite à partir d'une autre image, la valeur de **FROM** est **scratch**.+====1.4 - Rechercher une Image dans un Dépôt====
  
-====RUN====+Pour rechercher une image docker dans le dépôt par défaut, utilisez la commande **docker search** :
  
-<file+<code
-...+root@debian9:~# docker search --filter=stars=5 centos 
 +NAME                              DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED 
 +centos                            The official build of CentOS                  5288                [OK]                 
 +ansible/centos7-ansible           Ansible on Centos7                              121                                     [OK] 
 +jdeathe/centos-ssh                CentOS-6 6.10 x86_64 / CentOS-7 7.5.1804 x86…   107                                     [OK] 
 +consol/centos-xfce-vnc            Centos container with "headless" VNC session…   84                                      [OK] 
 +imagine10255/centos6-lnmp-php56   centos6-lnmp-php56                              53                                      [OK] 
 +centos/mysql-57-centos7           MySQL 5.7 SQL database server                   50                                       
 +tutum/centos                      Simple CentOS docker image with SSH access      44                                       
 +gluster/gluster-centos            Official GlusterFS Image [ CentOS-7 +  Glust…   40                                      [OK] 
 +openshift/base-centos7            A Centos7 derived base image for Source-To-I…   40                                       
 +centos/postgresql-96-centos7      PostgreSQL is an advanced Object-Relational …   37                                       
 +centos/python-35-centos7          Platform for building and running Python 3.5…   34                                       
 +kinogmt/centos-ssh                CentOS with SSH                                 26                                      [OK] 
 +centos/httpd-24-centos7           Platform for running Apache httpd 2.4 or bui…   22                                       
 +centos/php-56-centos7             Platform for building and running PHP 5.6 ap…   20                                       
 +openshift/jenkins-2-centos7       A Centos7 based Jenkins v2.x image for use w…   20                                       
 +pivotaldata/centos-gpdb-dev       CentOS image for GPDB development. Tag names…   10                                       
 +openshift/wildfly-101-centos7     A Centos7 based WildFly v10.1 image for use …                         
 +</code>
  
-RUN groupadd -r mongodb && useradd -r -g mongodb mongodb+<WRAP center round important> 
 +**Important** Notez que chaque image est référencée par la colonne NAME. Le NAME est sous le format **repository/mainteneur/nom** sauf dans le cas où il s'agit de l'image "officielle" de l'éditeur au quel cas le format est simplement **repository/nom**. La notion de STARS ( étoiles ) vient de Docker Hub et est une indication de la satisfaction de la communauté. 
 +</WRAP>
  
-RUN set -eux; \ +====1.Supprimer un Conteneur d'une Image====
- apt-get update; \ +
- apt-get install -y --no-install-recommends \ +
- ca-certificates \ +
- jq \ +
- numactl \ +
- ; \ +
- if ! command -v ps > /dev/null; then \ +
- apt-get install -y --no-install-recommends procps; \ +
- fi; \ +
- rm -rf /var/lib/apt/lists/+
-... +
-RUN set -ex; \ +
-+
- apt-get update; \ +
- apt-get install -y --no-install-recommends \ +
- wget \ +
- ; \ +
- if ! command -v gpg > /dev/null; then \ +
- apt-get install -y --no-install-recommends gnupg dirmngr; \ +
- fi; \ +
- rm -rf /var/lib/apt/lists/*;+
-+
- dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')";+
- wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch";+
- wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc";+
- export GNUPGHOME="$(mktemp -d)"; \ +
- gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4;+
- gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu;+
- command -v gpgconf && gpgconf --kill all || :; \ +
- rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc;+
- chmod +x /usr/local/bin/gosu;+
- gosu --version; \ +
- gosu nobody true; \ +
-+
- wget -O /js-yaml.js "https://github.com/nodeca/js-yaml/raw/${JSYAML_VERSION}/dist/js-yaml.js";+
-# TODO some sort of download verification here +
-+
- apt-get purge -y --auto-remove wget+
  
-RUN mkdir /docker-entrypoint-initdb.d +Pour supprimer un conteneur d'une image, il convient d'utiliser la commande **docker rm** en référencant le conteneur soit par son **NAME** soit par son CONTAINER ID :
-...+
  
-RUN set -ex; \ +<code> 
- export GNUPGHOME="$(mktemp -d)"; \ +root@debian9:~# docker ps -
- for key in $GPG_KEYS; do \ +CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                       PORTS               NAMES 
- gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ +3a3f9bda6cbd        ubuntu              "bash"              7 minutes ago       Exited (1275 minutes ago                       wizardly_buck 
- done; \ +26ef17bd115d        hello-world         "/hello           13 minutes ago      Exited (0) 13 minutes ago                        angry_chaplygin 
- gpg --batch --export $GPG_KEYS > /etc/apt/trusted.gpg.d/mongodb.gpg;+root@debian9:~# docker rm wizardly_buck 
- command -v gpgconf && gpgconf --kill all || :; \ +wizardly_buck 
- rm -r "$GNUPGHOME"; \ +root@debian9:~# docker ps -a 
- apt-key list +CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES 
-... +26ef17bd115d        hello-world         "/hello"            14 minutes ago      Exited (0) 14 minutes ago                       angry_chaplygin 
-RUN set -x \ +root@debian9:~# docker images 
- && apt-get update \ +REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE 
- && apt-get install -y \ +ubuntu              latest              94e814e2efa8        4 weeks ago         88.9MB 
- ${MONGO_PACKAGE}=$MONGO_VERSION \ +hello-world         latest              fce289e99eb9        3 months ago        4.84kB 
- ${MONGO_PACKAGE}-server=$MONGO_VERSION \ +</code>
- ${MONGO_PACKAGE}-shell=$MONGO_VERSION \ +
- ${MONGO_PACKAGE}-mongos=$MONGO_VERSION \ +
- ${MONGO_PACKAGE}-tools=$MONGO_VERSION \ +
- && rm -rf /var/lib/apt/lists/* \ +
- && rm -rf /var/lib/mongodb \ +
- && mv /etc/mongod.conf /etc/mongod.conf.orig+
  
-RUN mkdir -p /data/db /data/configdb \ +<WRAP center round important> 
- && chown -R mongodb:mongodb /data/db /data/configdb +**Important** Notez que dans le cas de l'utilisation du CONTAINER ID, il n'est pas necéssaire d'utiliser la totalité de l'IDPar exemple, dans le cas ci-dessus, le CONTAINER ID du conteneur **wizardly_buck** était **3a3f9bda6cbd**La commande de suppression aurait pu utilisé **3a3f9bda6cbd**, **3a3f9b** ou même **3a3**
-... +</WRAP>
-</file>+
  
-Cette commande lance un processus dans la construction de l'imageDans les cas ci-dessus, chaque chaîne correspond à la commande passée au shell **/bin/sh**.+====1.-Créer une Image à partir d'un Conteneur Modifié===
  
-Il existe un autre syntaxe de la commande RUN appelé le format exec, à savoir :+Modifier un conteneur d'une image :
  
-  RUN ["/bin/bash", "-c", "commande"]+<code> 
 +root@debian9:~# docker run -it ubuntu 
 +root@54b0dae2f3a9:/# ls 
 +bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var 
 +root@54b0dae2f3a9:/# rm -rf /home 
 +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:~#  
 +</code>
  
 <WRAP center round important> <WRAP center round important>
-**Important** : La commande RUN est utilisée pour exécuter une commande passée en argument lors de la compilation de l'image seulement. Cette commande ne doit pas donc être utilisée pour exécuter une commande lors du lancement du conteneur. La commande utilisée pour accomplir ce dernier est ENTRYPOINT.+**Important** - Notez ici la suppression du répertoire **home** dans le conteneur **54b0dae2f3a9**.
 </WRAP> </WRAP>
  
-====ENV====+Consultez la différence entre le conteneur et l'image de base :
  
-Cette commande permet de fixer la valeur d'une variable d'environnement disponible dans la suite du Dockerfile +<code> 
 +root@debian9:~# docker ps -a 
 +CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS                          PORTS               NAMES 
 +54b0dae2f3a9        ubuntu              "/bin/bash"         About a minute ago   Exited (0) About a minute ago                       tender_mendeleev 
 +26ef17bd115d        hello-world         "/hello"            18 minutes ago       Exited (0) 18 minutes ago                           angry_chaplygin 
 +root@debian9:~# docker diff tender_mendeleev 
 +C /root 
 +A /root/.bash_history 
 +D /home 
 +</code>
  
-<file+<WRAP center round important
-... +**Important** La sortie de la commande **docker diff** comporte des lettres dont les significations sont les suivantes C = Create, D = Delete, A = Add. 
-ENV GOSU_VERSION 1.11 +</WRAP>
-# grab "js-yaml" for parsing mongod's YAML config files (https://github.com/nodeca/js-yaml/releases) +
-ENV JSYAML_VERSION 3.13.0 +
-...+
  
-ENV GPG_KEYS E162F504A20CDF15827F718D4B7C549A058F8B6B +Créez un autre conteneur à partir de l'image de base :
-...+
  
-ENV MONGO_PACKAGE=${MONGO_PACKAGE} MONGO_REPO=${MONGO_REPO}+<code> 
 +root@debian9:~# docker run -it ubuntu 
 +root@92f0d4bb7967:/# ls 
 +bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var 
 +root@92f0d4bb7967:/# exit 
 +exit 
 +root@debian9:~#  
 +</code>
  
-ENV MONGO_MAJOR 4.1 +<WRAP center round important> 
-ENV MONGO_VERSION 4.1.95 +**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'image d'origine, inchangée depuis sa compilation
-..+</WRAP>
-</file>+
  
-**et** dans les conteneurs générés à partir de l'image construite.+Créez maintenant l'image **ubuntu_1** à partir du conteneur **competent_pasteur** en utilisant la commande **docker commit** :
  
-====VOLUME====+<code> 
 +root@debian9:~# docker ps -a 
 +CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES 
 +92f0d4bb7967        ubuntu              "/bin/bash"         39 seconds ago      Exited (0) 32 seconds ago                       musing_benz 
 +54b0dae2f3a9        ubuntu              "/bin/bash"         3 minutes ago       Exited (0) 3 minutes ago                        tender_mendeleev 
 +26ef17bd115d        hello-world         "/hello"            19 minutes ago      Exited (0) 19 minutes ago                       angry_chaplygin 
 +root@debian9:~# docker commit tender_mendeleev ubuntu_1 
 +sha256:2ba8e0ec5e38332c8ab15c4b33fd140a9c74d72231d05a6965c40a39fbb44584 
 +root@debian9:~# docker images 
 +REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE 
 +ubuntu_1            latest              2ba8e0ec5e38        15 seconds ago      88.9MB 
 +ubuntu              latest              94e814e2efa8        4 weeks ago         88.9MB 
 +hello-world         latest              fce289e99eb9        3 months ago        4.84kB 
 +</code>
  
-<file> +====1.7 - Supprimer une Image====
-... +
-VOLUME /data/db /data/configdb +
-... +
-</file>+
  
-Cette commande expose les répertoires passés en argument afin qu'ils puissent être mappés vers des répertoires sur la machine hôte ou ailleurs, tel que nous avons vu avec l'exemple nginx.+Créez maintenant un conteneur à partir de la nouvelle image **ubuntu_1** :
  
-====COPY====+<code> 
 +root@debian9:~# docker run -it ubuntu_1 
 +root@904215fb79b4:/# ls 
 +bin  boot  dev  etc  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var 
 +root@904215fb79b4:/# exit 
 +exit 
 +root@debian9:~#  
 +</code>
  
-<file+<WRAP center round important
-... +**Important** Notez l'absence du répertoire **home** dans le conteneur **904215fb79b4**
-COPY docker-entrypoint.sh /usr/local/bin/ +</WRAP>
-..+
-</file>+
  
-Cette commande permet de récupérer les fichiers dans le contexte et de les copier dans l'image.+Essayez de supprimer l'image **ubuntu_1** :
  
-Rappelez-vous de l'avertissement précédent **Attention** tous les fichiers dans le contexte sont inclus dans l'image finale, même ceux qui sont inutiles. +<code> 
- +root@debian9:~# docker rmi ubuntu_1 
-Il est possible d'exclure des fichiers présents dans le contexte en les mettant dans un fichier appelé **.dockerignore** placé dans le contexte.+Error response from daemonconflict: unable to remove repository reference "ubuntu_1" (must force) - container 904215fb79b4 is using its referenced image 2ba8e0ec5e38 
 +root@debian9:~# docker ps -a 
 +CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS                      PORTS               NAMES 
 +904215fb79b4        ubuntu_1            "/bin/bash"         About a minute ago   Exited (0) 49 seconds ago                       priceless_swirles 
 +92f0d4bb7967        ubuntu              "/bin/bash"         2 minutes ago        Exited (0) 2 minutes ago                        musing_benz 
 +54b0dae2f3a9        ubuntu              "/bin/bash"         6 minutes ago        Exited (0) 5 minutes ago                        tender_mendeleev 
 +26ef17bd115d        hello-world         "/hello"            22 minutes ago       Exited (0) 22 minutes ago                       angry_chaplygin 
 +</code>
  
 <WRAP center round important> <WRAP center round important>
-**Important** - Il existe une autre commande similaire à COPY : ADD. ADD est une commande qui n'est plus recommendé sauf dans le cas de cas spécifiques. Notez que dans le cas de l'utilisation de la commande ADD, si le fichier source est une archive de type TAR, son contenu sera désarchivé et copier vers la destination tandis que si le fichier source est référencé par un URL, le contenu sera téléchargé puis déposé dans la destination.+**Important** - Notez qu'il n'est pas possible de supprimer l'image **ubuntu_1** tant que le conteneur **priceless_swirles** soit actif.
 </WRAP> </WRAP>
  
-====ENTRYPOINT====+Supprimez donc le conteneur **priceless_swirles** ainsi que l'image **ubuntu_1** :
  
-<file+<code
-... +root@debian9:~# docker rm priceless_swirles 
-ENTRYPOINT ["docker-entrypoint.sh"] +priceless_swirles 
-... +root@debian9:~# docker ps -
-</file>+CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES 
 +92f0d4bb7967        ubuntu              "/bin/bash"         4 minutes ago       Exited (0) 3 minutes ago                        musing_benz 
 +54b0dae2f3a9        ubuntu              "/bin/bash"         7 minutes ago       Exited (0) 6 minutes ago                        tender_mendeleev 
 +26ef17bd115d        hello-world         "/hello"            23 minutes ago      Exited (0) 23 minutes ago                       angry_chaplygin 
 +root@debian9:~# docker rmi ubuntu_1 
 +Untagged: ubuntu_1:latest 
 +Deleted: sha256:2ba8e0ec5e38332c8ab15c4b33fd140a9c74d72231d05a6965c40a39fbb44584 
 +Deleted: sha256:308e9761a8fc84661e46eff564b0bbca12b458e71bdf77bf4abbb59b21efdbbe 
 +root@debian9:~# docker images 
 +REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE 
 +ubuntu              latest              94e814e2efa8        4 weeks ago         88.9MB 
 +hello-world         latest              fce289e99eb9        3 months ago        1.84kB 
 +</code>
  
-Cette commande stipule la commande qui sera exécutée lors du démarrage du conteneur.+Pour pouvoir supprimer tous les conteneurs, listez-les par leur **Container ID** :
  
-Deux cas de figure se présentent :+<code> 
 +root@debian9:~# docker ps -aq 
 +92f0d4bb7967 
 +54b0dae2f3a9 
 +26ef17bd115d 
 +</code>
  
-  * ENTRYPOINT suivi d'une chaîne - un shell est démarré pour exécuter la chaîne, +Supprimer toutes les conteneurs :
-  * ENTRYPOINT suivi d'une table JSON ( comme ci-dessus ) au format ENTRYPOINT ["commande à exécuter", "paramètres de la commande"].+
  
-Dans le fichier **docker-entrypoint.sh** :+<code> 
 +root@debian9:~# docker rm `docker ps -aq` 
 +92f0d4bb7967 
 +54b0dae2f3a9 
 +26ef17bd115d 
 +root@debian9:~# docker ps -aq 
 +root@debian9:~#  
 +</code>
  
-<file> +Pour supprimer un conteneur dès la fin de son exécution, utilisez l'option **--rm** :
-... +
-originalArgOne="$1"+
  
-allow the container to be started with `--user` +<code> 
-all mongo* commands should be dropped to the correct user +root@debian9:~docker run -it --rm ubuntu 
-if [[ "$originalArgOne" == mongo* ]] && [ "$(id -u)" = '0' ]; then +root@d123b0112fc2:/ls 
- if [ "$originalArgOne" = 'mongod' ]; then +bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var 
- find /data/configdb /data/db \! -user mongodb -exec chown mongodb '{}' + +root@d123b0112fc2:/# exit 
- fi+exit 
 +root@debian9:~# docker ps -aq 
 +root@debian9:~#  
 +</code>
  
- # make sure we can write to stdout and stderr as "mongodb" +====1.Créer un Conteneur avec un Nom Spécifique====
- # (for our "initdb" code later; see "--logpath" below) +
- chown --dereference mongodb "/proc/$$/fd/1" "/proc/$$/fd/2" || : +
- # ignore errors thanks to https://github.com/docker-library/mongo/issues/149+
  
- exec gosu mongodb "$BASH_SOURCE" "$@" +Créez maintenant un conteneur avec un nom spécifique :
-fi+
  
-# you should use numactl to start your mongod instances, including the config servers, mongos instances, and any clients. +<code> 
-# https://docs.mongodb.com/manual/administration/production-notes/#configuring-numa-on-linux +root@debian9:~docker run -it --name=i2tch ubuntu 
-if [[ "$originalArgOne" == mongo* ]]; then +root@04b5ab87539a:/# ls 
- numa='numactl --interleave=all' +bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var 
- if $numa true &> /dev/null; then +root@04b5ab87539a:/# exit 
- set -- $numa "$@" +exit 
- fi +root@debian9:~# docker ps -a 
-fi +CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES 
-... +04b5ab87539a        ubuntu              "/bin/bash        11 seconds ago      Exited (0) 4 seconds ago                       i2tch 
-exec "$@+</code>
-</file>+
  
-si la valeur du paramètre passé à entrypoint.sh est **mongod**, le script affecte l'utilisateur mongodb aux répertoires /data/configdb et /data/db puis lance mongo sous l'utilisateur mongodb avec des droits réduits ( gosu ). +Pour obtenir de l'information concernant un conteneur, utilisez la commande **docker inspect** :
- +
-Ce fichier finit par "$@" qui indique que si aucune condition n'ait été remplie, la commande est exécutée avec la valeur passée en argument :+
  
 <code> <code>
-root@debian9:~/mongodb# docker rm -fv mongo2 +root@debian9:~# docker inspect i2tch 
-mongo2 +
-root@debian9:~/mongodb# docker run -it --name mongo2 i2tch/mongodb2 /bin/bash +    { 
-root@a2b3a0f53f62:/# pwd +        "Id": "04b5ab87539aed114cbfc3ba15d10be61cd88b9cffc88c6de9bd26e203b363b5", 
-+        "Created": "2019-04-09T14:22:45.623162229Z", 
-root@a2b3a0f53f62:/# exit +        "Path": "/bin/bash", 
-exit +        "Args"[], 
-root@debian9:~/mongodb# +        "State":
 +            "Status": "exited", 
 +            "Running": false, 
 +            "Paused": false, 
 +            "Restarting": false, 
 +            "OOMKilled": false, 
 +            "Dead": false, 
 +            "Pid": 0, 
 +            "ExitCode": 0, 
 +            "Error": "", 
 +            "StartedAt": "2019-04-09T14:22:46.301514689Z", 
 +            "FinishedAt": "2019-04-09T14:22:51.91071787Z" 
 +        }, 
 +        "Image": "sha256:94e814e2efa8845d95b2112d54497fbad173e45121ce9255b93401392f538499", 
 +        "ResolvConfPath": "/var/lib/docker/containers/04b5ab87539aed114cbfc3ba15d10be61cd88b9cffc88c6de9bd26e203b363b5/resolv.conf", 
 +        "HostnamePath": "/var/lib/docker/containers/04b5ab87539aed114cbfc3ba15d10be61cd88b9cffc88c6de9bd26e203b363b5/hostname", 
 +        "HostsPath": "/var/lib/docker/containers/04b5ab87539aed114cbfc3ba15d10be61cd88b9cffc88c6de9bd26e203b363b5/hosts", 
 +        "LogPath": "/var/lib/docker/containers/04b5ab87539aed114cbfc3ba15d10be61cd88b9cffc88c6de9bd26e203b363b5/04b5ab87539aed114cbfc3ba15d10be61cd88b9cffc88c6de9bd26e203b363b5-json.log", 
 +        "Name": "/i2tch", 
 +        "RestartCount": 0, 
 +        "Driver": "overlay2", 
 +        "Platform": "linux", 
 +        "MountLabel": "", 
 +        "ProcessLabel": "", 
 +        "AppArmorProfile": "", 
 +        "ExecIDs": null, 
 +        "HostConfig":
 +            "Binds": null, 
 +            "ContainerIDFile": "", 
 +            "LogConfig":
 +                "Type": "json-file", 
 +                "Config": {} 
 +            }, 
 +            "NetworkMode": "default", 
 +            "PortBindings": {}, 
 +            "RestartPolicy":
 +                "Name": "no", 
 +                "MaximumRetryCount":
 +            }, 
 +            "AutoRemove": false, 
 +            "VolumeDriver": "", 
 +            "VolumesFrom": null, 
 +            "CapAdd": null, 
 +            "CapDrop": null, 
 +            "Dns": [], 
 +            "DnsOptions": [], 
 +            "DnsSearch": [], 
 +            "ExtraHosts": null, 
 +            "GroupAdd": null, 
 +            "IpcMode": "shareable", 
 +            "Cgroup": "", 
 +            "Links": null, 
 +            "OomScoreAdj": 0, 
 +            "PidMode": "", 
 +            "Privileged": false, 
 +            "PublishAllPorts": false, 
 +            "ReadonlyRootfs": false, 
 +            "SecurityOpt": null, 
 +            "UTSMode": "", 
 +            "UsernsMode": "", 
 +            "ShmSize": 67108864, 
 +            "Runtime": "runc", 
 +            "ConsoleSize":
 +                0, 
 +                0 
 +            ], 
 +            "Isolation": "", 
 +            "CpuShares": 0, 
 +            "Memory": 0, 
 +            "NanoCpus": 0, 
 +            "CgroupParent": "", 
 +            "BlkioWeight": 0, 
 +            "BlkioWeightDevice": [], 
 +            "BlkioDeviceReadBps": null, 
 +            "BlkioDeviceWriteBps": null, 
 +            "BlkioDeviceReadIOps": null, 
 +            "BlkioDeviceWriteIOps": null, 
 +            "CpuPeriod": 0, 
 +            "CpuQuota": 0, 
 +            "CpuRealtimePeriod": 0, 
 +            "CpuRealtimeRuntime": 0, 
 +            "CpusetCpus": "", 
 +            "CpusetMems": "", 
 +            "Devices": [], 
 +            "DeviceCgroupRules": null, 
 +            "DiskQuota": 0, 
 +            "KernelMemory": 0, 
 +            "MemoryReservation": 0, 
 +            "MemorySwap": 0, 
 +            "MemorySwappiness": null, 
 +            "OomKillDisable": false, 
 +            "PidsLimit": 0, 
 +            "Ulimits": null, 
 +            "CpuCount": 0, 
 +            "CpuPercent": 0, 
 +            "IOMaximumIOps": 0, 
 +            "IOMaximumBandwidth": 0, 
 +            "MaskedPaths":
 +                "/proc/asound", 
 +                "/proc/acpi", 
 +                "/proc/kcore", 
 +                "/proc/keys", 
 +                "/proc/latency_stats", 
 +                "/proc/timer_list", 
 +                "/proc/timer_stats", 
 +                "/proc/sched_debug", 
 +                "/proc/scsi", 
 +                "/sys/firmware" 
 +            ], 
 +            "ReadonlyPaths":
 +                "/proc/bus", 
 +                "/proc/fs", 
 +                "/proc/irq", 
 +                "/proc/sys", 
 +                "/proc/sysrq-trigger" 
 +            ] 
 +        }, 
 +        "GraphDriver":
 +            "Data":
 +                "LowerDir": "/var/lib/docker/overlay2/1151d32cdd4dda25ee299fe2c2a8df9dcb1b7fc4c47701c2925c437fb7c3a616-init/diff:/var/lib/docker/overlay2/84bcc6977e49ee3d477255450d69b98195b721b017124194b376f6e6c0645233/diff:/var/lib/docker/overlay2/eee0d6bc849e0c074de73e17eaf11b296dd860a0fb17097f37f9af86d28dcf9b/diff:/var/lib/docker/overlay2/0deb30449649adfed4d1abb678939b2409c4804976ceea4cb75508d0fdf415b6/diff:/var/lib/docker/overlay2/a156bf77423d93e38ef326b3ca6a1d0248ce801733800dad2767070380d682b6/diff", 
 +                "MergedDir""/var/lib/docker/overlay2/1151d32cdd4dda25ee299fe2c2a8df9dcb1b7fc4c47701c2925c437fb7c3a616/merged", 
 +                "UpperDir": "/var/lib/docker/overlay2/1151d32cdd4dda25ee299fe2c2a8df9dcb1b7fc4c47701c2925c437fb7c3a616/diff", 
 +                "WorkDir""/var/lib/docker/overlay2/1151d32cdd4dda25ee299fe2c2a8df9dcb1b7fc4c47701c2925c437fb7c3a616/work" 
 +            }, 
 +            "Name""overlay2" 
 +        }, 
 +        "Mounts": [], 
 +        "Config":
 +            "Hostname": "04b5ab87539a", 
 +            "Domainname": "", 
 +            "User": "", 
 +            "AttachStdin": true, 
 +            "AttachStdout": true, 
 +            "AttachStderr": true, 
 +            "Tty": true, 
 +            "OpenStdin": true, 
 +            "StdinOnce": true, 
 +            "Env":
 +                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 
 +            ], 
 +            "Cmd":
 +                "/bin/bash" 
 +            ], 
 +            "ArgsEscaped": true, 
 +            "Image": "ubuntu", 
 +            "Volumes": null, 
 +            "WorkingDir": "", 
 +            "Entrypoint": null, 
 +            "OnBuild": null, 
 +            "Labels": {} 
 +        }, 
 +        "NetworkSettings":
 +            "Bridge": "", 
 +            "SandboxID": "304fc54e6d23247d4faf08995b65646967670def542812d902d2ee33d178794d", 
 +            "HairpinMode": false, 
 +            "LinkLocalIPv6Address": "", 
 +            "LinkLocalIPv6PrefixLen": 0, 
 +            "Ports": {}, 
 +            "SandboxKey": "/var/run/docker/netns/304fc54e6d23", 
 +            "SecondaryIPAddresses": null, 
 +            "SecondaryIPv6Addresses": null, 
 +            "EndpointID": "", 
 +            "Gateway": "", 
 +            "GlobalIPv6Address": "", 
 +            "GlobalIPv6PrefixLen": 0, 
 +            "IPAddress": "", 
 +            "IPPrefixLen": 0, 
 +            "IPv6Gateway": "", 
 +            "MacAddress": "", 
 +            "Networks":
 +                "bridge":
 +                    "IPAMConfig": null, 
 +                    "Links": null, 
 +                    "Aliases": null, 
 +                    "NetworkID": "f2d947904cba4a871af3e50d6e1ec0a3a055849185bf7ba473b2e028880bd8a9", 
 +                    "EndpointID": "", 
 +                    "Gateway": "", 
 +                    "IPAddress": "", 
 +                    "IPPrefixLen": 0, 
 +                    "IPv6Gateway": "", 
 +                    "GlobalIPv6Address": "", 
 +                    "GlobalIPv6PrefixLen": 0, 
 +                    "MacAddress": "", 
 +                    "DriverOpts": null 
 +                } 
 +            } 
 +        } 
 +    } 
 +]
 </code> </code>
  
-<WRAP center round important> +====1.9 Exécuter une Commande dans un Conteneur====
-**Important** Notez que la compilation d'une image se fait à l'intérieur d'un **contexte**. Le **contexte** est le répertoire de build. **Attention** : tous les fichiers dans le contexte sont inclus dans l'image finale, même ceux qui sont inutiles. Dernièrement, notez qu'il peut y avoir plusieurs ENTRYPOINT dans le fichier Dockerfile mais uniquement le dernier est pris en compte. +
-</WRAP>+
  
-====EXPOSE====+Pour exécuter une commande spécifique dans un conteneur, passez la commande en argument :
  
-<file+<code
-... +root@debian9:~# docker run --rm ubuntu env 
-EXPOSE 27017 +PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 
-... +HOSTNAME=77bb110031aa 
-</file>+HOME=/root 
 +root@debian9:~#  
 +</code>
  
-Cette commande permet d'exposer un port à l'extérieur du conteneur :+====1.10 - Injecter des Variables d'Environnement dans un Conteneur==== 
 + 
 +Pour injecter une ou des variables d'environnement dans un conteneur, utilisez un fichier pré-établi :
  
 <code> <code>
-root@debian9:~/mongodbdocker rm -fv mongo2 +root@debian9:~# vi env.list 
-mongo2 +root@debian9:~# cat env.list 
-root@debian9:~/mongodbdocker run -d --name mongo2 i2tch/mongodb2 +EDITOR=vim 
-b3380889eb750298710e956f284f291b786f4382465d247ae58f9b73d2d276ca +HOSTNAME=ubuntudocker
-root@debian9:~/mongodb# docker ps -a +
-CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS                NAMES +
-b3380889eb75        i2tch/mongodb2      "docker-entrypoint.s…"   15 seconds ago      Up 15 seconds               27017/tcp            mongo2 +
-bf72bd700870        i2tch/mongodb1      "/bin/bash"              19 minutes ago      Exited (0) 19 minutes ago                        mongo1 +
-d2ddb4f8ca8a        i2tch/mongodb       "bash"                   31 minutes ago      Up 29 minutes                                    mongo +
-c080793965de        nginx               "nginx -g 'daemon of…"   About an hour ago   Up About an hour            0.0.0.0:81->80/tcp   suspicious_sanderson +
-4f157e179134        nginx               "nginx -g 'daemon of…"   4 hours ago         Exited (0) 4 hours ago                           stoic_roentgen +
-04b5ab87539a        ubuntu              "/bin/bash"              4 hours ago         Exited (0) 4 hours ago                           i2tch+
 </code> </code>
  
-====CMD====+<code> 
 +root@debian9:~# docker run --rm --env-file=env.list ubuntu env 
 +PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 
 +HOSTNAME=ubuntudocker 
 +EDITOR=vim 
 +HOME=/root 
 +root@debian9:~#  
 +</code>
  
-<file> +====1.11 - Modifier le Nom d'Hôte d'un Conteneur====
-... +
-CMD ["mongod"+
-... +
-</file>+
  
-Ceci représente la valeur du paramètre par défaut si aucun paramètre n'est spécifié à la fin de la commande docker run.+Pour modifier le nom d'hôte d'un conteneur, utilisez l'option **-h** :
  
-====Autres Commandes====+<code> 
 +root@debian9:~# docker run -it --rm -h ubuntudocker ubuntu 
 +root@ubuntudocker:/# hostname 
 +ubuntudocker 
 +root@ubuntudocker:/# exit 
 +exit 
 +root@debian9:~#  
 +</code>
  
-Le Dockerfile peut aussi contenir les commandes suivantes :+====1.12 - Mapper des Ports d'un Conteneur=====
  
-  * **WORKDIR**, +Démarrer un conteneur de nginx sur le port localhost 81 :
-    * Cette commande fixe le répertoire de travil lors de la compilation d'une image. Elle peut apparaître plusieurs fois dans le Dockerfile permettant ainsi l'évolution du répertoire de travail, +
-  * **LABEL**, +
-    * Cette commande permet de définir des couples clef/valeur à inclure dans les méta-données décrivant l'image lors de sa distribution, par exemple, la **version**, la **description** ou un **readme**.+
  
 +<code>
 +root@debian9:~# docker run -it -p 81:80 nginx
 +Unable to find image 'nginx:latest' locally
 +latest: Pulling from library/nginx
 +27833a3ba0a5: Pull complete 
 +e83729dd399a: Pull complete 
 +ebc6a67df66d: Pull complete 
 +Digest: sha256:c8a861b8a1eeef6d48955a6c6d5dff8e2580f13ff4d0f549e082e7c82a8617a2
 +Status: Downloaded newer image for nginx:latest
 +^Croot@debian9:~# 
 +</code>
  
-Lancez maintenant la compilation de l'image :+Notez que c'est bloquant. Le fait d'avoir utiliser ^C a interrompu le processus du conteneur :
  
 <code> <code>
-root@debian9:~/mongodb# docker build .+^Croot@debian9:~# docker ps -a 
 +CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS               NAMES 
 +4f157e179134        nginx               "nginx -g 'daemon of…"   32 seconds ago      Exited (0) 21 seconds ago                       stoic_roentgen 
 +04b5ab87539a        ubuntu              "/bin/bash"              5 minutes ago       Exited (0) 5 minutes ago                        i2tch
 </code> </code>
  
-Consultez la liste de images :+====1.13 - Démarrer un Conteneur en mode Détaché==== 
 + 
 +Démarrez maintenant le conteneur de nginx en mode détaché grâce à l'utilisation de l'option **-d** :
  
 <code> <code>
-root@debian9:~/mongodb# docker images +root@debian9:~# docker run -d -p 81:80 nginx 
-REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE +aabb064d4b0ade1f19216b6174631fa32a2053f6aa9d59bd724ea90ce534b004 
-<none>              <none>              3bf216d921d6        About a minute ago   96.2MB +root@debian9:~# docker ps -a 
-i2tch/mongodb       latest              eca7835d4fe6        11 minutes ago       1.03GB +CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS                          PORTS                NAMES 
-nginx               latest              2bcb04bdb83f        13 days ago          109MB +aabb064d4b0a        nginx               "nginx -g 'daemon of…"   12 seconds ago       Up 11 seconds                   0.0.0.0:81->80/tcp   eager_lewin 
-centos              latest              9f38484d220f        3 weeks ago          202MB +4f157e179134        nginx               "nginx -g 'daemon of…"   About a minute ago   Exited (0) About a minute ago                        stoic_roentgen 
-ubuntu              bionic              94e814e2efa8        4 weeks ago          88.9MB +04b5ab87539a        ubuntu              "/bin/bash"              6 minutes ago        Exited (0) 6 minutes ago                             i2tch
-ubuntu              latest              94e814e2efa8        4 weeks ago          88.9MB +
-hello-world         latest              fce289e99eb9        3 months ago         1.84kB+
 </code> </code>
  
-Notez que l'image n'a ni REPOSITORY, ni TAGCréez donc un TAG :+====1.14 - Accèder aux Services d'un Conteneur de l'Extérieur==== 
 + 
 +Installez le navigateur texte **lynx** 
  
 <code> <code>
-root@debian9:~/mongodbdocker tag 3bf2 i2tch/mongodb1 +root@debian9:~# apt-get install lynx 
-root@debian9:~/mongodb# docker images +Lecture des listes de paquets... Fait 
-REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE +Construction de l'arbre des dépendances        
-i2tch/mongodb1      latest              3bf216d921d6        minutes ago       96.2MB +Lecture des informations d'état... Fait 
-i2tch/mongodb       latest              eca7835d4fe6        11 minutes ago      1.03GB +The following additional packages will be installed: 
-nginx               latest              2bcb04bdb83f        13 days ago         109MB +  lynx-common 
-centos              latest              9f38484d220f        weeks ago         202MB +Les NOUVEAUX paquets suivants seront installés : 
-ubuntu              bionic              94e814e2efa8        4 weeks ago         88.9MB +  lynx lynx-common 
-ubuntu              latest              94e814e2efa8        4 weeks ago         88.9MB +0 mis à jour, 2 nouvellement installés, 0 à enlever et 94 non mis à jour. 
-hello-world         latest              fce289e99eb9        3 months ago        1.84kB+Il est nécessaire de prendre 1 730 ko dans les archives. 
 +Après cette opération, 5 590 ko d'espace disque supplémentaires seront utilisés. 
 +Souhaitez-vous continuer ? [O/n] o 
 +Réception de:1 http://ftp.fr.debian.org/debian stretch/main amd64 lynx-common all 2.8.9dev11-1 [1 098 kB] 
 +Réception de:2 http://ftp.fr.debian.org/debian stretch/main amd64 lynx amd64 2.8.9dev11-1 [632 kB] 
 +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 .../lynx-common_2.8.9dev11-1_all.deb ... 
 +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 .../lynx_2.8.9dev11-1_amd64.deb ... 
 +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: utilisation de « /usr/bin/lynx » pour fournir « /usr/bin/www-browser » (www-browser) en mode automatique
 </code> </code>
  
-Démarrez un conteneur à partir de l'image i2tch/mongodb1 :+Vérifiez que nginx répond aux requetes :
  
 <code> <code>
-root@debian9:~/mongodbdocker run ---name mongo1 i2tch/mongodb1 +root@debian9:~# lynx --dump http://localhost:81 
-bdb4bc0f81de8b5821f20d8609b9640abaaae7b4a7577c42b78d4bd34617d211 +                               Welcome to nginx! 
-docker: Error response from daemon: oci runtime error: container_linux.go:262: starting container process caused "exec: \"docker-entrypoint.sh\": executable file not found in $PATH"+ 
-root@debian9:~/mongodb# ls -l +   If you see this page, the nginx web server is successfully installed 
-total 16 +   and workingFurther configuration is required. 
--rw-r--r-- root root 10971 avril  9 13:56 docker-entrypoint.sh + 
--rw-r--r-- 1 root root  3542 avril  9 13:55 Dockerfile+   For online documentation and support please refer to [1]nginx.org. 
 +   Commercial support is available at [2]nginx.com. 
 + 
 +   Thank you for using nginx
 + 
 +Références 
 + 
 +   1. http://nginx.org/ 
 +   2. http://nginx.com/
 </code> </code>
  
-<WRAP center round important> +====1.15 Arrêter et Démarrer un Conteneur====
-**Important** Notez que le fichier docker-entrypoint.sh n'était pas exécutable ! +
-</WRAP>+
  
-Recompilez donc l'image :+Arrêtez le conteneur nginx :
  
 <code> <code>
-root@debian9:~/mongodbchmod +x docker-entrypoint.sh +root@debian9:~# docker ps -a 
-root@debian9:~/mongodb# docker build . +CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                     PORTS                NAMES 
-Sending build context to Docker daemon   16.9kB +aabb064d4b0a        nginx               "nginx -g 'daemon of…"   2 minutes ago       Up 2 minutes               0.0.0.0:81->80/tcp   eager_lewin 
-Step 1/22 FROM ubuntu:bionic +4f157e179134        nginx               "nginx -g 'daemon of…"   4 minutes ago       Exited (0) minutes ago                        stoic_roentgen 
- ---> 94e814e2efa8 +04b5ab87539a        ubuntu              "/bin/bash"              8 minutes ago       Exited (0) 8 minutes ago                        i2tch 
-Step 2/22 : RUN groupadd -r mongodb && useradd -r -g mongodb mongodb +root@debian9:~# docker stop aabb 
- ---> Using cache +aabb 
- ---> f40ac453fa97 +root@debian9:~# docker ps -a 
-Step 3/22 : RUN set -eux; apt-get update; apt-get install -y --no-install-recommends ca-certificates jq numactl ; if ! command -v ps > /dev/null; then apt-get install -y --no-install-recommends procps; fi; rm -rf /var/lib/apt/lists/* +CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                     PORTS               NAMES 
- ---> Using cache +aabb064d4b0a        nginx               "nginx -g 'daemon of…  2 minutes ago       Exited (0) 2 seconds ago                       eager_lewin 
- ---> adc57da1b19f +4f157e179134        nginx               "nginx -g 'daemon of…"   4 minutes ago       Exited (0) 4 minutes ago                       stoic_roentgen 
-Step 4/22 : ENV GOSU_VERSION 1.11 +04b5ab87539a        ubuntu              "/bin/bash             8 minutes ago       Exited (0) 8 minutes ago                       i2tch
- ---> Using cache +
- ---> 038e7de870b7 +
-Step 5/22 : ENV JSYAML_VERSION 3.13.+
- ---> Using cache +
- ---> 3bf216d921d6 +
-... +
-Removing intermediate container a98ae692fe1f +
- ---> 04c2e98927c3 +
-Step 17/22 RUN mkdir -p /data/db /data/configdb && chown -R mongodb:mongodb /data/db /data/configdb +
- ---> Running in d0f5bee34571 +
-Removing intermediate container d0f5bee34571 +
- ---> d5b95e9e63e1 +
-Step 18/22 VOLUME /data/db /data/configdb +
- ---> Running in c7626528a9b9 +
-Removing intermediate container c7626528a9b9 +
- ---> 4250613adf6a +
-Step 19/22 : COPY docker-entrypoint.sh /usr/local/bin/ +
- ---> eedfd53da0f8 +
-Step 20/22 : ENTRYPOINT ["docker-entrypoint.sh"] +
- ---> Running in eff53d0213d1 +
-Removing intermediate container eff53d0213d1 +
- ---> 716abf2faa87 +
-Step 21/22 : EXPOSE 27017 +
- ---> Running in 5139fcf19d7f +
-Removing intermediate container 5139fcf19d7f +
- ---> fc5896e08fd6 +
-Step 22/22 : CMD ["mongod"+
- ---> Running in 458d6f15cdf2 +
-Removing intermediate container 458d6f15cdf2 +
- ---> 12e00099ca8d +
-Successfully built 12e00099ca8d +
-root@debian9:~/mongodb# +
 </code> </code>
  
-<WRAP center round important> +Démarrez de nouveau le conteneur de nginx :
-**Important** - Notez ici les lignes **Using cache**. Il est cependant possible de ne pas utiliser le cache en stipulant **--no-cache**. Notez aussi l'utilisation de conteneurs temporaires par étape nouvelle avec un commit vers une image et une suppression dudit conteneur. Dernièrement, notez que la compilation d'une image se fait à l'intérieur d'un **contexte**. Le **contexte** est le répertoire de build. **Attention** : tous les fichiers dans le contexte sont inclus dans l'image finale, même ceux qui sont inutiles. +
-</WRAP> +
- +
-Consultez la liste des images de nouveau et renommez votre dernière image :+
  
 <code> <code>
-root@debian9:~/mongodb# docker images +root@debian9:~# docker start aabb 
-REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE +aabb 
-<none>              <none>              12e00099ca8d        42 seconds ago      377MB +root@debian9:~# docker ps -a 
-i2tch/mongodb1      latest              3bf216d921d6        10 minutes ago      96.2MB +CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                     PORTS                NAMES 
-i2tch/mongodb       latest              eca7835d4fe6        19 minutes ago      1.03GB +aabb064d4b0a        nginx               "nginx -g 'daemon of…"   minutes ago       Up 3 seconds               0.0.0.0:81->80/tcp   eager_lewin 
-nginx               latest              2bcb04bdb83f        13 days ago         109MB +4f157e179134        nginx               "nginx -g 'daemon of…"   minutes ago       Exited (0) 4 minutes ago                        stoic_roentgen 
-centos              latest              9f38484d220f        3 weeks ago         202MB +04b5ab87539a        ubuntu              "/bin/bash"              9 minutes ago       Exited (0) 8 minutes ago                        i2tch
-ubuntu              bionic              94e814e2efa8        4 weeks ago         88.9MB +
-ubuntu              latest              94e814e2efa8        4 weeks ago         88.9MB +
-hello-world         latest              fce289e99eb9        3 months ago        1.84kB +
-root@debian9:~/mongodb# docker tag 12e0 i2tch/mongodb2 +
-root@debian9:~/mongodb# docker images +
-REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE +
-i2tch/mongodb2      latest              12e00099ca8d        About a minute ago   377MB +
-i2tch/mongodb1      latest              3bf216d921d6        11 minutes ago       96.2MB +
-i2tch/mongodb       latest              eca7835d4fe6        20 minutes ago       1.03GB +
-nginx               latest              2bcb04bdb83f        13 days ago          109MB +
-centos              latest              9f38484d220f        3 weeks ago          202MB +
-ubuntu              bionic              94e814e2efa8        4 weeks ago          88.9MB +
-ubuntu              latest              94e814e2efa8        4 weeks ago          88.9MB +
-hello-world         latest              fce289e99eb9        3 months ago         1.84kB+
 </code> </code>
  
-Lancez un conteneur à partir de la dernière image :+====1.16 - Utiliser des Signaux avec un Conteneur==== 
 + 
 +Utilisez un signal pour tuer le processus du conteneur de nginx :
  
 <code> <code>
-root@debian9:~/mongodb# docker run ---name mongo2 i2tch/mongodb2 +root@debian9:~# docker kill -s 9 aabb 
-e91a055283f4d67cbd91d11bb3faa6f67925893cb18f9cc25023e72e0f7ed85a+aabb 
 +root@debian9:~# docker ps -
 +CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                       PORTS               NAMES 
 +aabb064d4b0a        nginx               "nginx -g 'daemon of…"   2 hours ago         Exited (137) 2 seconds ago                       eager_lewin 
 +4f157e179134        nginx               "nginx -g 'daemon of…"   2 hours ago         Exited (0) 2 hours ago                           stoic_roentgen 
 +04b5ab87539a        ubuntu              "/bin/bash"              2 hours ago         Exited (0) 2 hours ago                           i2tch
 </code> </code>
  
-Utilisez la commande **docker ps** pour visualiser si le processus mongodb est bien démarré :+Redémarrez un conteneur en cours :
  
 <code> <code>
-root@debian9:~/mongodb# docker ps +root@debian9:~# docker start aabb 
-CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES +aabb 
-e91a055283f4        i2tch/mongodb2      "docker-entrypoint.s…"   28 seconds ago      Up 27 seconds       27017/tcp            mongo2 +root@debian9:~# docker ps -a 
-d2ddb4f8ca8a        i2tch/mongodb       "bash"                   21 minutes ago      Up 19 minutes                            mongo +CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                   PORTS                NAMES 
-c080793965de        nginx               "nginx -g 'daemon of…"   About an hour ago   Up About an hour    0.0.0.0:81->80/tcp   suspicious_sanderson+aabb064d4b0a        nginx               "nginx -g 'daemon of…"   2 hours ago         Up 1 second              0.0.0.0:81->80/tcp   eager_lewin 
 +4f157e179134        nginx               "nginx -g 'daemon of…"   2 hours ago         Exited (0) 2 hours ago                        stoic_roentgen 
 +04b5ab87539a        ubuntu              "/bin/bash"              2 hours ago         Exited (0) 2 hours ago                        i2tch 
 +root@debian9:~# docker restart aabb 
 +aabb 
 +root@debian9:~# docker ps -a 
 +CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                   PORTS                NAMES 
 +aabb064d4b0a        nginx               "nginx -g 'daemon of…"   2 hours ago         Up 2 seconds             0.0.0.0:81->80/tcp   eager_lewin 
 +4f157e179134        nginx               "nginx -g 'daemon of…"   2 hours ago         Exited (0) 2 hours ago                        stoic_roentgen 
 +04b5ab87539a        ubuntu              "/bin/bash"              2 hours ago         Exited (0) 2 hours ago                        i2tch
 </code> </code>
  
-Connectez-vous à mongodb à partir de votre machine hôte :+====1.17 Forcer la Suppression d'un Conteneur en cours d'Exécution==== 
 + 
 +Supprimez un conteneur en cours d'exécution :
  
 <code> <code>
-root@debian9:~/mongodb# docker inspect mongo2 | grep IP +root@debian9:~# docker rm aabb 
-            "LinkLocalIPv6Address""", +Error response from daemonYou cannot remove a running container aabb064d4b0ade1f19216b6174631fa32a2053f6aa9d59bd724ea90ce534b004. Stop the container before attempting removal or force remove 
-            "LinkLocalIPv6PrefixLen"0, +root@debian9:~# docker ps -a 
-            "SecondaryIPAddresses": null, +CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                   PORTS                NAMES 
-            "SecondaryIPv6Addresses": null, +aabb064d4b0a        nginx               "nginx -g 'daemon of…  2 hours ago         Up About a minute        0.0.0.0:81->80/tcp   eager_lewin 
-            "GlobalIPv6Address": "", +4f157e179134        nginx               "nginx -g 'daemon of…  2 hours ago         Exited (0) 2 hours ago                        stoic_roentgen 
-            "GlobalIPv6PrefixLen": 0+04b5ab87539a        ubuntu              "/bin/bash             2 hours ago         Exited (0) 2 hours ago                        i2tch 
-            "IPAddress": "172.17.0.4", +root@debian9:~# docker rm -f aabb 
-            "IPPrefixLen"16, +aabb 
-            "IPv6Gateway": "", +root@debian9:~# docker ps -a 
-                    "IPAMConfig": null, +CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                   PORTS               NAMES 
-                    "IPAddress": "172.17.0.4", +4f157e179134        nginx               "nginx -g 'daemon of…  2 hours ago         Exited (02 hours ago                       stoic_roentgen 
-                    "IPPrefixLen": 16, +04b5ab87539a        ubuntu              "/bin/bash"              2 hours ago         Exited (02 hours ago                       i2tch 
-                    "IPv6Gateway": "", +</code>
-                    "GlobalIPv6Address": "", +
-                    "GlobalIPv6PrefixLen": 0, +
-root@debian9:~/mongodb+
-root@debian9:~/mongodbmongo --host 172.17.0.4 +
-MongoDB shell version v4.0.8 +
-connecting to: mongodb://172.17.0.4:27017/?gssapiServiceName=mongodb +
-Implicit session: session { "id: UUID("3feff8c0-5460-473b-b036-4aee64a314f7"} +
-MongoDB server version: 4.1.9 +
-WARNING: shell and server versions do not match +
-Server has startup warnings:  +
-2019-04-09T17:50:12.635+0000 I STORAGE  [initandlisten]  +
-2019-04-09T17:50:12.636+0000 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine +
-2019-04-09T17:50:12.636+0000 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem +
-2019-04-09T17:50:13.458+0000 I CONTROL  [initandlisten]  +
-2019-04-09T17:50:13.459+0000 I CONTROL  [initandlisten] ** NOTE: This is a development version (4.1.9of MongoDB. +
-2019-04-09T17:50:13.459+0000 I CONTROL  [initandlisten] **       Not recommended for production. +
-2019-04-09T17:50:13.459+0000 I CONTROL  [initandlisten]  +
-2019-04-09T17:50:13.459+0000 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database. +
-2019-04-09T17:50:13.459+0000 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted. +
-2019-04-09T17:50:13.460+0000 I CONTROL  [initandlisten]  +
---- +
-Enable MongoDB's free cloud-based monitoring service, which will then receive and display +
-metrics about your deployment (disk utilization, CPU, operation statistics, etc).+
  
-The monitoring data will be available on a MongoDB website with a unique URL accessible to you +===1.18 - Utilisation Simple d'un Volume===
-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() +Créez le fichier index.html et placez-le dans le répertoire /root/www :
-To permanently disable this reminder, run the following commanddb.disableFreeMonitoring() +
----+
  
-exit +<code
-bye +root@debian9:~# mkdir /root/www 
-root@debian9:~/mongodb#+root@debian9:~# vi index.html 
 +root@debian9:~# cat index.html 
 +<html> 
 +<body> 
 +<center>Accueil du site nginx</center> 
 +</body> 
 +</html> 
 +root@debian9:~mv index.html www/
 </code> </code>
  
-Notez que lors de la compilation de l'image finale, une image a été créée lors de chaque instruction dans le fichier Dockerfile sauf en cas d'utilisation d'une image en cache :+Indiquez au conteneur que son répertoire **/usr/share/nginx/html/** est remplacé par le répertoire **/root/www/** de la machine hôte :
  
 <code> <code>
-root@debian9:~/mongodb# docker images -+root@debian9:~# docker run -d -p 81:80 -v /root/www:/usr/share/nginx/html:ro nginx 
-REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE +c080793965de8a6a60db212d7e4d96de84b55352c224c054dced75b409e39bf2 
-i2tch/mongodb2      latest              12e00099ca8d        5 minutes ago       377MB +root@debian9:~# lynx --dump http://localhost:81 
-<none>              <none>              d5b95e9e63e1        5 minutes ago       377MB +                            Accueil du site nginx 
-<none>              <none>              4250613adf6a        5 minutes ago       377MB + 
-<none>              <none>              eedfd53da0f8        5 minutes ago       377MB + 
-<none>              <none>              04c2e98927c3        5 minutes ago       377MB +root@debian9:~# 
-<none>              <none>              c6eae79e3d22        7 minutes ago       110MB +
-<none>              <none>              c205179d538c        7 minutes ago       110MB +
-<none>              <none>              b70835bebe35        7 minutes ago       110MB +
-<none>              <none>              5b2827910929        7 minutes ago       110MB +
-<none>              <none>              5b1f6df94d98        7 minutes ago       110MB +
-<none>              <none>              a950a5d04b68        7 minutes ago       110MB +
-<none>              <none>              c183cfecc5f0        7 minutes ago       110MB +
-<none>              <none>              aadb5806f1b8        8 minutes ago       110MB +
-<none>              <none>              8d538d38407e        8 minutes ago       110MB +
-<none>              <none>              32d59bf23987        8 minutes ago       110MB +
-i2tch/mongodb1      latest              3bf216d921d6        15 minutes ago      96.2MB +
-<none>              <none>              038e7de870b7        15 minutes ago      96.2MB +
-<none>              <none>              adc57da1b19f        15 minutes ago      96.2MB +
-<none>              <none>              f40ac453fa97        15 minutes ago      89.3MB +
-i2tch/mongodb       latest              eca7835d4fe6        24 minutes ago      1.03GB +
-<none>              <none>              620057baa411        27 minutes ago      816MB +
-<none>              <none>              67afc80e1424        33 minutes ago      816MB +
-nginx               latest              2bcb04bdb83f        13 days ago         109MB +
-centos              latest              9f38484d220f        3 weeks ago         202MB +
-ubuntu              bionic              94e814e2efa8        4 weeks ago         88.9MB +
-ubuntu              latest              94e814e2efa8        4 weeks ago         88.9MB +
-hello-world         latest              fce289e99eb9        3 months ago        1.84kB+
 </code> </code>
  
-=====LAB #5 Créer un Dockerfile=====+<WRAP center round important> 
 +**Important** Notez ici l'utilisation de **ro** - lecture seule. 
 +</WRAP>
  
-====Création et test du script====+====1.19 - Télécharger une image sans créer un conteneur====
  
-Créez un répertoire nommé myDocker :+Téléchargez l'image de centos sans créer un conteneur :
  
 <code> <code>
-root@debian9:~/mongodbmkdir ~/myDocker +root@debian9:~# docker pull centos 
-root@debian9:~/mongodb# cd ~/myDocker +Using default taglatest 
-root@debian9:~/myDocker# +latestPulling from library/centos 
 +8ba884070f61: Pull complete  
 +Digest: sha256:8d487d68857f5bc9595793279b33d082b03713341ddec91054382641d14db861 
 +Status: Downloaded newer image for centos:latest
 </code> </code>
  
-Créez le fichier myEntrypoint.sh :+Vérifiez le contenu de l'image en créant un conteneur :
  
 <code> <code>
-root@debian9:~/myDockervi myEntrypoint.sh +root@debian9:~# docker run -it centos bash 
-root@debian9:~/myDocker# cat myEntrypoint.sh  +[root@86252a3f00f4 /]# cat /etc/redhat-release 
-#!/bin/bash +CentOS Linux release 7.6.1810 (Core)  
-if [ -z "$myVariable" ]; then +[root@86252a3f00f4 /]# rpm -qa | more 
- echo "La variable myVariable doit être renseignée" +bind-license-9.9.4-73.el7_6.noarch 
- return +bash-4.2.46-31.el7.x86_64 
-fi+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-- 
 +</code>
  
-while true; +====1.20 - S'attacher à un conteneur en cours d'exécution==== 
-do + 
- echo $1 \($(date +%H:%M:%S)\); +Arretez le conteneur. Démarrez le conteneur puis rattachez-vous au conteneur : 
- sleep "$myVariable"; + 
-done+<code> 
 +[root@86252a3f00f4 /]# exit 
 +exit 
 +root@debian9:~# docker ps -a 
 +CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS                       PORTS                NAMES 
 +86252a3f00f4        centos              "bash"                   About a minute ago   Exited (1276 seconds ago                        vibrant_mccarthy 
 +c080793965de        nginx               "nginx -g 'daemon of…"   4 minutes ago        Up 4 minutes                 0.0.0.0:81->80/tcp   suspicious_sanderson 
 +4f157e179134        nginx               "nginx -g 'daemon of…"   3 hours ago          Exited (03 hours ago                            stoic_roentgen 
 +04b5ab87539a        ubuntu              "/bin/bash             3 hours ago          Exited (0) 3 hours ago                            i2tch 
 +root@debian9:~# docker start 8625 
 +8625 
 +root@debian9:~# docker attach 8625 
 +[root@86252a3f00f4 /]# ls 
 +anaconda-post.log  bin  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var 
 +[root@86252a3f00f4 /]# 
 </code> </code>
  
-Testez ce script :+====1.21 - Installer un logiciel dans le conteneur=== 
 + 
 +Réparez les dépôts de CentOS 8 :
  
 <code> <code>
-root@debian9:~/myDockermyVariable=3 . ./myEntrypoint.sh salut +[root@86252a3f00f4 /]sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-* 
-salut (20:04:39) +[root@86252a3f00f4 /]# sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-* 
-salut (20:04:42) +[root@86252a3f00f4 /]yum upgrade -y
-salut (20:04:45) +
-salut (20:04:48) +
-salut (20:04:51) +
-^C +
-root@debian9:~/myDocker+
 </code> </code>
  
-Rendez ce script exécutable :+Créez le fichier **/etc/yum.repos.d/mongodb-org-4.2.repo** :
  
 <code> <code>
-root@debian9:~/myDockerchmod u+x myEntrypoint.sh +[root@86252a3f00f4 /]vi /etc/yum.repos.d/mongodb-org-4.2.repo 
 +[root@86252a3f00f4 /]# cat /etc/yum.repos.d/mongodb-org-4.2.repo 
 +[mongodb-org-4.2] 
 +name=MongoDB Repository 
 +baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/ 
 +gpgcheck=1 
 +enabled=1 
 +gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc 
 +[root@86252a3f00f4 /]# 
 </code> </code>
  
-Créez maintenant le fichier **Dockerfile** dans le répertoire **~/myDocker** :+Installez mongo :
  
 <code> <code>
-root@debian9:~/myDockervi Dockerfile +[root@86252a3f00f4 /]yum install -y mongodb-org
-root@debian9:~/myDocker# cat Dockerfile +
-FROM centos:latest +
-MAINTAINER i2tch "infos@i2tch.eu" +
-COPY myEntrypoint.sh /entrypoint.sh +
-ENV myVariable 3 +
-ENTRYPOINT ["/entrypoint.sh"+
-CMD ["mycommand"]+
 </code> </code>
  
-Générez maintenant l'image :+Démarrez mongod :
  
 <code> <code>
-root@debian9:~/myDockerdocker build -t i2tch/mydocker +[root@86252a3f00f4 /]mongod --config /etc/mongod.conf & 
-Sending build context to Docker daemon  3.072kB +[1] 82 
-Step 1/6 : FROM centos:latest +[root@86252a3f00f4 /]# about to fork child process, waiting until server is ready for connections
- ---> 9f38484d220f +forked process84 
-Step 2/6 : MAINTAINER i2tch "infos@i2tch.eu" +child process started successfully, parent exiting 
- ---> Running in 02c700ed04da + 
-Removing intermediate container 02c700ed04da +[1]+  Done                    mongod --config /etc/mongod.conf 
- ---> 4274107d52e2 +[root@86252a3f00f4 /]#  
-Step 3/6 : COPY myEntrypoint.sh /entrypoint.sh +
- ---> 7a3923372768 +
-Step 4/6 ENV myVariable 3 +
- ---> Running in 3288bf6291ad +
-Removing intermediate container 3288bf6291ad +
- ---> 3edb630c1511 +
-Step 5/6 : ENTRYPOINT ["/entrypoint.sh"] +
- ---> Running in 8dcba2c41520 +
-Removing intermediate container 8dcba2c41520 +
- ---> 11962052539c +
-Step 6/6 : CMD ["mycommand"] +
- ---> Running in f891fbcfaad0 +
-Removing intermediate container f891fbcfaad0 +
- ---> 7925ba23abb2 +
-Successfully built 7925ba23abb2 +
-Successfully tagged i2tch/mydocker:latest+
 </code> </code>
  
-Lancez le conteneur :+Vérifiez que mongod est démarré :
  
 <code> <code>
-root@debian9:~/myDockerdocker run -it --name myDocker i2tch/mydocker +[root@86252a3f00f4 /]ps aux 
-mycommand (18:07:12) +USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND 
-mycommand (18:07:15) +root          0.0  0.1  11828  2996 pts/0    Ss   16:57   0:00 bash 
-mycommand (18:07:18) +root        84  1.2  2.2 294692 46716 ?        Sl   17:16   0:00 mongod --config /etc/mongod.conf 
-mycommand (18:07:21) +root       103  0.0  0.1  51748  3444 pts/0    R+   17:17   0:00 ps aux
-^Cmycommand (18:07:22) +
-mycommand (18:07:25) +
-mycommand (18:07:28) +
-^P^Q +
-root@debian9:~/myDocker#+
 </code> </code>
  
-Constatez que le conteneur est toujours en cours de fonctionnement :+Utilisez le client mongo pour se connecter au serveur :
  
 <code> <code>
-root@debian9:~/myDockerdocker ps +[root@86252a3f00f4 /]mongo 
-CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS                NAMES +MongoDB shell version: 4.2.2 
-140ecfdd80b7        i2tch/mydocker      "/entrypoint.sh myco…  About a minute ago   Up About a minute                        myDocker +connecting to: test 
-b3380889eb75        i2tch/mongodb2      "docker-entrypoint.s…"   7 minutes ago        Up 7 minutes        27017/tcp            mongo2 +Welcome to the MongoDB shell. 
-d2ddb4f8ca8a        i2tch/mongodb       "bash"                   38 minutes ago       Up 36 minutes                            mongo +For interactive help, type "help". 
-c080793965de        nginx               "nginx -g 'daemon of…"   About an hour ago    Up About an hour    0.0.0.0:81->80/tcp   suspicious_sanderson +For more comprehensive documentation, see 
-root@debian9:~/myDocker# + http://docs.mongodb.org
-root@debian9:~/myDocker# docker logs myDocker | tail +Questions? Try the support group 
-mycommand (18:08:25) + http://groups.google.com/group/mongodb-user 
-mycommand (18:08:28) +Server has startup warnings:  
-mycommand (18:08:31) +2019-04-09T17:16:26.951+0000 I CONTROL  [initandlisten] ** WARNINGYou are running this process as the root user, which is not recommended. 
-mycommand (18:08:34) +2019-04-09T17:16:26.951+0000 I CONTROL  [initandlisten]  
-mycommand (18:08:37) +
-mycommand (18:08:40) +
-mycommand (18:08:43) +
-mycommand (18:08:46) +
-mycommand (18:08:49) +
-mycommand (18:08:52)+
 </code> </code>
  
-Arrêtez le conteneur :+Sortez de mongo et du conteneur :
  
 <code> <code>
-root@debian9:~/myDockerdocker stop -t 1 myDocker +> exit 
-myDocker +bye 
-root@debian9:~/myDockerdocker ps +[root@86252a3f00f4 /]exit 
-CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES +exit 
-b3380889eb75        i2tch/mongodb2      "docker-entrypoint.s…"   9 minutes ago       Up 9 minutes        27017/tcp            mongo2 +root@debian9:~# 
-d2ddb4f8ca8a        i2tch/mongodb       "bash"                   40 minutes ago      Up 38 minutes                            mongo +
-c080793965de        nginx               "nginx -g 'daemon of…"   About an hour ago   Up About an hour    0.0.0.0:81->80/tcp   suspicious_sanderson+
 </code> </code>
  
-Démarrez le conteneur :+====1.22 - Utilisation de la commande docker commit==== 
 + 
 +Créez maintenant une nouvelle image à partir de votre conteneur :
  
 <code> <code>
-root@debian9:~/myDocker# docker start myDocker +root@debian9:~# docker ps -a 
-myDocker +CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS                NAMES 
-root@debian9:~/myDocker# docker ps +86252a3f00f4        centos              "bash"                   23 minutes ago      Exited (0) 56 seconds ago                        vibrant_mccarthy 
-CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES +c080793965de        nginx               "nginx -g 'daemon of…"   26 minutes ago      Up 26 minutes               0.0.0.0:81->80/tcp   suspicious_sanderson 
-140ecfdd80b7        i2tch/mydocker      "/entrypoint.sh myco…"   3 minutes ago       Up 10 seconds                            myDocker +4f157e179134        nginx               "nginx -g 'daemon of…"   3 hours ago         Exited (0) 3 hours ago                           stoic_roentgen 
-b3380889eb75        i2tch/mongodb2      "docker-entrypoint.s…"   10 minutes ago      Up 10 minutes       27017/tcp            mongo2 +04b5ab87539a        ubuntu              "/bin/bash"              3 hours ago         Exited (0) 3 hours ago                           i2tch 
-d2ddb4f8ca8a        i2tch/mongodb       "bash"                   40 minutes ago      Up 38 minutes                            mongo +root@debian9:~# docker commit 8625 i2tch/mongodb 
-c080793965de        nginx               "nginx -g 'daemon of…"   About an hour ago   Up About an hour    0.0.0.0:81->80/tcp   suspicious_sanderson+sha256:67afc80e1424a6d99179911ee499f6bf264faf2bc3c7ff4ac4a01ff9c23050a9
 </code> </code>
  
-Mettez le conteneur en pause :+Supprimez le conteneur utilisé pour créer l'image :
  
 <code> <code>
-root@debian9:~/myDocker# docker pause myDocker +root@debian9:~# docker rm 8625 
-myDocker +8625 
-root@debian9:~/myDocker# docker ps+root@debian9:~# docker ps -a
 CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                   PORTS                NAMES CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                   PORTS                NAMES
-140ecfdd80b7        i2tch/mydocker      "/entrypoint.sh myco…"   3 minutes ago       Up 51 seconds (Paused)                        myDocker +c080793965de        nginx               "nginx -g 'daemon of…"   28 minutes ago      Up 28 minutes            0.0.0.0:81->80/tcp   suspicious_sanderson 
-b3380889eb75        i2tch/mongodb2      "docker-entrypoint.s…"   10 minutes ago      Up 10 minutes            27017/tcp            mongo2 +4f157e179134        nginx               "nginx -g 'daemon of…"   3 hours ago         Exited (0) 3 hours ago                        stoic_roentgen 
-d2ddb4f8ca8a        i2tch/mongodb       "bash"                   41 minutes ago      Up 39 minutes                                 mongo +04b5ab87539a        ubuntu              "/bin/bash"              3 hours ago         Exited (0) 3 hours ago                        i2tch
-c080793965de        nginx               "nginx -g 'daemon of…"   About an hour ago   Up About an hour         0.0.0.0:81->80/tcp   suspicious_sanderson+
 </code> </code>
  
-Supprimez la pause :+Utilisez la nouvelle image pour lancer un conteneur nommé **mongo** :
  
 <code> <code>
-root@debian9:~/myDocker# docker unpause myDocker +root@debian9:~# docker run -it --name mongo i2tch/mongodb 
-myDocker +[root@d20fb56a38b0 /]ls /usr/bin/mongo* 
-root@debian9:~/myDockerdocker ps +/usr/bin/mongo   /usr/bin/mongodump    /usr/bin/mongofiles   /usr/bin/mongooplog  /usr/bin/mongorestore  /usr/bin/mongostat 
-CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES +/usr/bin/mongod  /usr/bin/mongoexport  /usr/bin/mongoimport  /usr/bin/mongoperf   /usr/bin/mongos        /usr/bin/mongotop 
-140ecfdd80b7        i2tch/mydocker      "/entrypoint.sh myco…"   4 minutes ago       Up About a minute                        myDocker +[root@d20fb56a38b0 /]# ps aux 
-b3380889eb75        i2tch/mongodb2      "docker-entrypoint.s…"   11 minutes ago      Up 11 minutes       27017/tcp            mongo2 +USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND 
-d2ddb4f8ca8a        i2tch/mongodb       "bash"                   42 minutes ago      Up 40 minutes                            mongo +root          0.1  0.1  11828  2972 pts/0    Ss   17:22   0:00 bash 
-c080793965de        nginx               "nginx -g 'daemon of…"   About an hour ago   Up About an hour    0.0.0.0:81->80/tcp   suspicious_sanderson+root        15  0.0  0.1  51748  3468 pts/   R+   17:23   0:00 ps aux
 </code> </code>
  
-Lancez maintenant le conteneur avec un paramètre :+Editez le fichier /etc/bashrc :
  
 <code> <code>
-root@debian9:~/myDockerdocker rm -fv myDocker +[root@d20fb56a38b0 /]echo "/usr/bin/mongod --config /etc/mongod.conf &" >> /etc/bashrc 
-myDocker +[root@d20fb56a38b0 /]tail /etc/bashrc 
-root@debian9:~/myDockerdocker run -d --name myDocker i2tch/mydocker "Up and Running+                . "$i>/dev/null 
-0cf8c8c1bdf4cb05d9852900ecdf171ad9abad0fce29a9f040d5d8436285db65 +            fi 
-root@debian9:~/myDocker# docker logs myDocker +        fi 
-Up and Running (18:13:33) +    done 
-Up and Running (18:13:36) + 
-Up and Running (18:13:39) +    unset i 
-Up and Running (18:13:42) +    unset -f pathmunge 
-root@debian9:~/myDocker# +fi 
 +# vim:ts=4:sw=4 
 +/usr/bin/mongod --config /etc/mongod.conf &
 </code> </code>
  
-Changez la valeur de la variable d'environnement **myVariable** :+Consultez la liste des conteneurs et relevez le CONTAINER ID du conteneur **mongo** :
  
 <code> <code>
-root@debian9:~/myDockerdocker rm -fv myDocker +[root@d20fb56a38b0 /]exit 
-myDocker +exit 
-root@debian9:~/myDocker# docker run -d --name myDocker --env myVariable=1 i2tch/mydocker +root@debian9:~# docker ps -a 
-fbbe3b48c63310e37a3bad5fc962361c39c045a107f47980614efd6b2e8d3981 +CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                     PORTS                NAMES 
-root@debian9:~/myDocker# docker logs myDocker +d20fb56a38b0        i2tch/mongodb       "bash"                   2 minutes ago       Exited (04 seconds ago                        mongo 
-mycommand (18:14:47+c080793965de        nginx               "nginx -g 'daemon of…"   32 minutes ago      Up 32 minutes              0.0.0.0:81->80/tcp   suspicious_sanderson 
-mycommand (18:14:48) +4f157e179134        nginx               "nginx -g 'daemon of…"   3 hours ago         Exited (03 hours ago                          stoic_roentgen 
-mycommand (18:14:49+04b5ab87539a        ubuntu              "/bin/bash"              3 hours ago         Exited (03 hours ago                          i2tch
-mycommand (18:14:50) +
-mycommand (18:14:51) +
-mycommand (18:14:52) +
-mycommand (18:14:53) +
-mycommand (18:14:54) +
-mycommand (18:14:55) +
-mycommand (18:14:56) +
-mycommand (18:14:57) +
-root@debian9:~/myDocker# +
 </code> </code>
  
-====Bonnes Pratiques liées au Cache====+Utilisez la commande commit pour "sauvegarder" la modification dans l'image :
  
-===Opérations Non-Idempotentes===+<code> 
 +root@debian9:~# docker commit d20f i2tch/mongodb 
 +sha256:620057baa411b78a0030e192fdfbde0bb0c5ceae7bdeb115892d9946e542ee07 
 +</code>
  
-Créez un répertoire **bestp** ainsi que le fichier Dockerfile suivant :+Démarrez de nouveau le conteneur pour vérifier que mongod fonctionne :
  
 <code> <code>
-root@debian9:~/myDockercd .. +root@debian9:~# docker rm d20f 
-root@debian9:~# mkdir bestp +d20f 
-root@debian9:~# cd bestp +root@debian9:~# docker ps -a 
-root@debian9:~/bestpvi Dockerfile +CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                   PORTS                NAMES 
-root@debian9:~/bestpcat Dockerfile +c080793965de        nginx               "nginx -g 'daemon of…"   33 minutes ago      Up 33 minutes            0.0.0.0:81->80/tcp   suspicious_sanderson 
-FROM ubuntu:latest +4f157e179134        nginx               "nginx -g 'daemon of…"   3 hours ago         Exited (0) 3 hours ago                        stoic_roentgen 
-RUN date +%N > /tmp/moment +04b5ab87539a        ubuntu              "/bin/bash"              3 hours ago         Exited (0) 3 hours ago                        i2tch 
-ENTRYPOINT ["more"+root@debian9:~# docker run -it --name mongo i2tch/mongodb 
-CMD ["/tmp/moment"]+[root@bcec3f27ed58 /]about to fork child process, waiting until server is ready for connections. 
 +forked process16 
 +child process started successfully, parent exiting 
 + 
 +[1] Done                    /usr/bin/mongod --config /etc/mongod.conf 
 +[root@bcec3f27ed58 /]# ps aux 
 +USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND 
 +root          0.0  0.1  11828  2920 pts/0    Ss   17:26   0:00 bash 
 +root        16  2.0  2.4 298788 49276 ?        Sl   17:26   0:01 /usr/bin/mongod --config /etc/mongod.conf 
 +root        39  0.0  0.1  51748  3476 pts/0    R+   17:27   0:00 ps aux 
 +[root@bcec3f27ed58 /]
 </code> </code>
  
-Le fichier Dokerfile contient une opération non idempotente.+====1.23 - Se connecter au serveur du conteneur de l'extérieur====
  
-<WRAP center round important> +Pour pouvoir se connecter à mongodb depuis la machine hôte, il convient d'éditer le fichier /etc/mongod.conf :
-**Important** : Une opération idempotente est une opération qui aboutit systématiquement au même résultat quand elle est lancée dans le même contexte. +
-</WRAP> +
- +
-Compilez l'image :+
  
 <code> <code>
-root@debian9:~/bestpdocker build -t testcache . +[root@bcec3f27ed58 /]vi /etc/mongod.conf 
-Sending build context to Docker daemon  2.048kB +[root@bcec3f27ed58 /]# cat /etc/mongod.conf | grep bindIp 
-Step 1/4 : FROM ubuntu:latest +   bindIp0.0.0.0
- ---> 94e814e2efa8 +
-Step 2/4 : RUN date +%N > /tmp/moment +
- ---> Running in 6c8c677c1549 +
-Removing intermediate container 6c8c677c1549 +
- ---> 66c3c88c57bb +
-Step 3/4 : ENTRYPOINT ["more"] +
- ---> Running in e9658e591172 +
-Removing intermediate container e9658e591172 +
- ---> 81cb68241ec9 +
-Step 4/4 : CMD ["/tmp/moment"+
- ---> Running in 48974dc12faa +
-Removing intermediate container 48974dc12faa +
- ---> c55a42a18572 +
-Successfully built c55a42a18572 +
-Successfully tagged testcache:latest +
-root@debian9:~/bestp#+
 </code> </code>
  
-Exécuter maintenant un premier conteneur à partir de l'image compilée :+Sortez du conteneur, re-créez une image, supprimez le conteneur utilisé et relancez de nouveau le conteneur :
  
 <code> <code>
-root@debian9:~/bestp# docker run --name test1 -it testcache +[root@bcec3f27ed58 /]# exit 
-369009216+exit 
 +root@debian9:~# docker commit mongo i2tch/mongodb 
 +sha256:eca7835d4fe6a3a769046bd735ef4ad7534ac1f9bb37832d6da5db3b938d258f 
 +root@debian9:~# docker rm mongo 
 +mongo 
 +root@debian9:~# docker run -it --name mongo i2tch/mongodb 
 +[root@d2ddb4f8ca8a /]# about to fork child process, waiting until server is ready for connections. 
 +forked process: 16 
 +[root@d2ddb4f8ca8a /]# child process started successfully, parent exiting 
 + 
 +[1]+  Done                    /usr/bin/mongod --config /etc/mongod.conf 
 +[root@d2ddb4f8ca8a /]# 
 </code> </code>
  
-Supprimez maintenant le conteneur et relancez la compilation de l'image :+Dans votre machine hôte, configurez le dépôt de mongodb :
  
 <code> <code>
-root@debian9:~/bestpdocker rm test1 +[root@f5b45072b831 /]# exit 
-test1 +root@debian9:~# 
-root@debian9:~/bestpdocker build -t testcache . +root@debian9:~# apt-get install dirmngr 
-Sending build context to Docker daemon  2.048kB +root@debian9:~# 
-Step 1/4 FROM ubuntu:latest +root@debian9:~# apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4 
- ---> 94e814e2efa8 +Executing: /tmp/apt-key-gpghome.xMuszKS6JM/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4 
-Step 2/4 RUN date +%N > /tmp/moment +gpgkey 68818C72E52529D4: public key "MongoDB 4.0 Release Signing Key <packaging@mongodb.com>imported 
- ---> Using cache +gpg: Total number processed: 1 
- ---> 66c3c88c57bb +gpg:               imported: 1 
-Step 3/4 ENTRYPOINT ["more"] +root@debian9:~#  
- ---> Using cache +root@debian9:~# echo "deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.0 main| tee /etc/apt/sources.list.d/mongodb-org-4.0.list 
- ---> 81cb68241ec9 +deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.0 main 
-Step 4/4 CMD ["/tmp/moment"+root@debian9:~#  
- ---> Using cache +root@debian9:~# apt-get update
- ---> c55a42a18572 +
-Successfully built c55a42a18572 +
-Successfully tagged testcache:latest +
-root@debian9:~/bestp+
 </code> </code>
  
-Lancez un conteneur à partir de l'image re-compilée :+Cette fois, installez uniquement le client de mongodb :
  
 <code> <code>
-root@debian9:~/bestpdocker run --name test1 -it testcache +root@debian9:~# apt-get install mongodb-org-shell 
-369009216+Lecture des listes de paquets... Fait 
 +Construction de l'arbre des dépendances        
 +Lecture des informations d'état... Fait 
 +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'espace disque supplémentaires seront utilisés. 
 +Réception de:1 http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.0/main amd64 mongodb-org-shell amd64 4.0.8 [9 809 kB] 
 +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 .../mongodb-org-shell_4.0.8_amd64.deb ... 
 +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) ...
 </code> </code>
  
-<WRAP center round important> +Notez qu'à ce stade le conteneur ne possède pas d'adresse IP car il n'est pas démarré :
-**Important** - Notez que les deux sorties des conteneurs sont identiques malgré le fait que la valeur de la commande date aurait du modifier le résultat obtenu lors de l'exécution du deuxième conteneur. La raison que ceci n'est pas le cas est l'utilisation dans la deuxième compilation du cache. Si cette commande avait été quelque chose de plus importante telle apt-get upgrade, le résultat pourrait être génant ! +
-</WRAP> +
- +
-Pour contourner ce problème, il est possible d'utiliser l'option **--no-cache**. Malheureusement ceci produirait une compilation complète à chaque fois, même pour les opérations idempotentes. Il est donc conseillé de combiner les opérations non-idempotentes avec des opérations idempotentes dans la même ligne de commande afin d'invalider le cache pour cette ligne de commande seulement :+
  
 <code> <code>
-root@debian9:~/bestpvi Dockerfile  +root@debian9:~# docker inspect mongo | grep IP 
-root@debian9:~/bestp# cat Dockerfile  +            "LinkLocalIPv6Address""", 
-FROM ubuntu:latest +            "LinkLocalIPv6PrefixLen"0, 
-RUN date +%N > /tmp/moment \ +            "SecondaryIPAddresses": null, 
-    && echo "V1.1> /tmp/version +            "SecondaryIPv6Addresses": null, 
-ENTRYPOINT ["more"] +            "GlobalIPv6Address": "", 
-CMD ["/tmp/moment"]+            "GlobalIPv6PrefixLen": 0, 
 +            "IPAddress": "", 
 +            "IPPrefixLen": 0, 
 +            "IPv6Gateway": "", 
 +                    "IPAMConfig": null, 
 +                    "IPAddress": "", 
 +                    "IPPrefixLen": 0, 
 +                    "IPv6Gateway": "", 
 +                    "GlobalIPv6Address": "", 
 +                    "GlobalIPv6PrefixLen": 0,
 </code> </code>
  
-Supprimez maintenant le conteneur et relancez la compilation de l'image :+Démarrez donc le conteneur et cherchez l'adresse IP de celui-ci :
  
 <code> <code>
-root@debian9:~/bestp# docker rm test1 +root@debian9:~# docker start mongo 
-test1 +mongo 
-root@debian9:~/bestp# docker build -t testcache . +root@debian9:~# docker inspect mongo | grep IP 
-Sending build context to Docker daemon  2.048kB +            "LinkLocalIPv6Address": "", 
-Step 1/4 FROM ubuntu:latest +            "LinkLocalIPv6PrefixLen"0, 
- ---> 94e814e2efa8 +            "SecondaryIPAddresses"null, 
-Step 2/4 RUN date +%N > /tmp/moment     && echo "V1.1> /tmp/version +            "SecondaryIPv6Addresses": null, 
- ---> Running in 3d2a5cee6ac8 +            "GlobalIPv6Address": "", 
-Removing intermediate container 3d2a5cee6ac8 +            "GlobalIPv6PrefixLen": 0, 
- ---> 75d0498a9676 +            "IPAddress": "172.17.0.3", 
-Step 3/4 ENTRYPOINT ["more"] +            "IPPrefixLen": 16, 
- ---> Running in 88c0cec68659 +            "IPv6Gateway": "", 
-Removing intermediate container 88c0cec68659 +                    "IPAMConfig": null, 
- ---> 2aee524c8da4 +                    "IPAddress": "172.17.0.3", 
-Step 4/4 CMD ["/tmp/moment"] +                    "IPPrefixLen": 16, 
- ---> Running in 82d2162bb701 +                    "IPv6Gateway": "", 
-Removing intermediate container 82d2162bb701 +                    "GlobalIPv6Address": "", 
- ---> a54c4af89994 +                    "GlobalIPv6PrefixLen"0,
-Successfully built a54c4af89994 +
-Successfully tagged testcache:latest+
 </code> </code>
  
-Lancez un conteneur à partir de l'image re-compilée :+Connectez-vous maintenant à votre mongodb à partir de la machine hôte :
  
 <code> <code>
-root@debian9:~/bestpdocker run --name test1 -it testcache +root@debian9:~# mongo --host 172.17.0.3 
-746997174+MongoDB shell version v4.0.8 
 +connecting to: mongodb://172.17.0.3:27017/?gssapiServiceName=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 "help"
 +For more comprehensive documentation, see 
 + http://docs.mongodb.org/ 
 +Questions? Try the support group 
 + http://groups.google.com/group/mongodb-user 
 +Server has startup warnings:  
 +2019-04-09T17:31:33.827+0000 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended. 
 +2019-04-09T17:31:33.827+0000 I CONTROL  [initandlisten]  
 +>   
 </code> </code>
  
 ----- -----
-<html> + 
-<div align="center"> +Copyright © 2022 Hugh Norris. 
-Copyright © 2020 Hugh NORRIS +
-</div> +
-</html>+
Menu