Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
elearning:workbooks:docker3:drf02 [2021/11/25 11:07] – admin | elearning:workbooks:docker3:drf02 [2024/02/21 13:41] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
~~PDF: | ~~PDF: | ||
- | Version : **2021.01** | + | Version : **2024.01** |
Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
Ligne 28: | Ligne 28: | ||
* 3.1 - Créer un Registre local, | * 3.1 - Créer un Registre local, | ||
* 3.2 - Créer un Serveur de Registre Dédié | * 3.2 - Créer un Serveur de Registre Dédié | ||
- | * Configurer le clone comme Registre Dédié | ||
* Configurer le Client | * Configurer le Client | ||
Ligne 38: | Ligne 37: | ||
< | < | ||
- | root@debian9:~# mkdir mongodb | + | root@debian11:~# mkdir mongodb |
- | root@debian9:~# cd mongodb/ | + | root@debian11:~# cd mongodb/ |
- | root@debian9:~/mongodb# touch Dockerfile docker-entrypoint.sh | + | root@debian11:~/mongodb# touch Dockerfile docker-entrypoint.sh |
</ | </ | ||
Le Docker file contient les instructions nécessaires pour la contruction de l' | Le Docker file contient les instructions nécessaires pour la contruction de l' | ||
- | <file txt Dockerfile> | + | <code> |
+ | root@debian11: | ||
+ | root@debian11: | ||
FROM ubuntu: | FROM ubuntu: | ||
Ligne 52: | Ligne 53: | ||
RUN set -eux; \ | RUN set -eux; \ | ||
- | apt-get update; \ | + | |
- | apt-get install -y --no-install-recommends \ | + | apt-get install -y --no-install-recommends \ |
- | ca-certificates \ | + | ca-certificates \ |
- | jq \ | + | jq \ |
- | numactl \ | + | numactl \ |
- | ; \ | + | ; \ |
- | if ! command -v ps > /dev/null; then \ | + | if ! command -v ps > /dev/null; then \ |
- | apt-get install -y --no-install-recommends procps; \ | + | apt-get install -y --no-install-recommends procps; \ |
- | fi; \ | + | fi; \ |
- | rm -rf / | + | rm -rf / |
# grab gosu for easy step-down from root (https:// | # grab gosu for easy step-down from root (https:// | ||
Ligne 69: | Ligne 70: | ||
RUN set -ex; \ | RUN set -ex; \ | ||
- | \ | + | |
- | apt-get update; \ | + | apt-get update; \ |
- | apt-get install -y --no-install-recommends \ | + | apt-get install -y --no-install-recommends \ |
- | wget \ | + | wget \ |
- | ; \ | + | ; \ |
- | if ! command -v gpg > /dev/null; then \ | + | if ! command -v gpg > /dev/null; then \ |
- | apt-get install -y --no-install-recommends gnupg dirmngr; \ | + | apt-get install -y --no-install-recommends gnupg dirmngr; \ |
- | fi; \ | + | fi; \ |
- | rm -rf / | + | rm -rf / |
- | \ | + | \ |
- | dpkgArch=" | + | dpkgArch=" |
- | wget -O / | + | wget -O / |
- | wget -O / | + | wget -O / |
- | export GNUPGHOME=" | + | export GNUPGHOME=" |
- | gpg --batch --keyserver | + | gpg --batch --keyserver |
- | # gpg --batch --verify / | + | # gpg --batch --verify / |
- | command -v gpgconf && gpgconf --kill all || :; \ | + | command -v gpgconf && gpgconf --kill all || :; \ |
- | rm -r " | + | rm -r " |
- | chmod +x / | + | chmod +x / |
- | gosu --version; \ | + | gosu --version; \ |
- | gosu nobody true; \ | + | gosu nobody true; \ |
- | \ | + | \ |
- | wget -O /js-yaml.js " | + | wget -O /js-yaml.js " |
# TODO some sort of download verification here | # TODO some sort of download verification here | ||
- | \ | + | |
- | apt-get purge -y --auto-remove wget | + | apt-get purge -y --auto-remove wget |
RUN mkdir / | RUN mkdir / | ||
Ligne 100: | Ligne 101: | ||
ENV GPG_KEYS E162F504A20CDF15827F718D4B7C549A058F8B6B | ENV GPG_KEYS E162F504A20CDF15827F718D4B7C549A058F8B6B | ||
RUN set -ex; \ | RUN set -ex; \ | ||
- | export GNUPGHOME=" | + | |
- | for key in $GPG_KEYS; do \ | + | for key in $GPG_KEYS; do \ |
- | gpg --batch --keyserver | + | gpg --batch --keyserver |
- | done; \ | + | done; \ |
- | gpg --batch --export $GPG_KEYS > / | + | gpg --batch --export $GPG_KEYS > / |
- | command -v gpgconf && gpgconf --kill all || :; \ | + | command -v gpgconf && gpgconf --kill all || :; \ |
- | rm -r " | + | rm -r " |
- | apt-key list | + | apt-key list |
# Allow build-time overrides (eg. to build image with MongoDB Enterprise version) | # Allow build-time overrides (eg. to build image with MongoDB Enterprise version) | ||
Ligne 123: | Ligne 124: | ||
RUN set -x \ | RUN set -x \ | ||
- | && apt-get update \ | + | |
- | && apt-get install -y \ | + | && apt-get install -y \ |
- | ${MONGO_PACKAGE}=$MONGO_VERSION \ | + | ${MONGO_PACKAGE}=$MONGO_VERSION \ |
- | ${MONGO_PACKAGE}-server=$MONGO_VERSION \ | + | ${MONGO_PACKAGE}-server=$MONGO_VERSION \ |
- | ${MONGO_PACKAGE}-shell=$MONGO_VERSION \ | + | ${MONGO_PACKAGE}-shell=$MONGO_VERSION \ |
- | ${MONGO_PACKAGE}-mongos=$MONGO_VERSION \ | + | ${MONGO_PACKAGE}-mongos=$MONGO_VERSION \ |
- | ${MONGO_PACKAGE}-tools=$MONGO_VERSION \ | + | ${MONGO_PACKAGE}-tools=$MONGO_VERSION \ |
- | && rm -rf / | + | && rm -rf / |
- | && rm -rf / | + | && rm -rf / |
- | && mv / | + | && mv / |
RUN mkdir -p /data/db / | RUN mkdir -p /data/db / | ||
- | && chown -R mongodb: | + | |
VOLUME /data/db / | VOLUME /data/db / | ||
Ligne 143: | Ligne 144: | ||
EXPOSE 27017 | EXPOSE 27017 | ||
CMD [" | CMD [" | ||
- | </file> | + | </code> |
Le fichier docker-entrypoint.sh sert à lancer le serveur mongodb dans le conteneur : | Le fichier docker-entrypoint.sh sert à lancer le serveur mongodb dans le conteneur : | ||
- | <file txt docker-entrypoint.sh> | + | <code> |
+ | root@debian11: | ||
+ | root@debian11: | ||
#!/bin/bash | #!/bin/bash | ||
set -Eeuo pipefail | set -Eeuo pipefail | ||
if [ " | if [ " | ||
- | set -- mongod " | + | |
fi | fi | ||
Ligne 160: | Ligne 163: | ||
# all mongo* commands should be dropped to the correct user | # all mongo* commands should be dropped to the correct user | ||
if [[ " | if [[ " | ||
- | if [ " | + | |
- | find / | + | find / |
- | fi | + | fi |
- | # make sure we can write to stdout and stderr as " | + | |
- | # (for our " | + | # (for our " |
- | chown --dereference mongodb "/ | + | chown --dereference mongodb "/ |
- | # ignore errors thanks to https:// | + | # ignore errors thanks to https:// |
- | exec gosu mongodb " | + | |
fi | fi | ||
Ligne 175: | Ligne 178: | ||
# https:// | # https:// | ||
if [[ " | if [[ " | ||
- | numa=' | + | |
- | if $numa true &> /dev/null; then | + | if $numa true &> /dev/null; then |
- | set -- $numa " | + | set -- $numa " |
- | fi | + | fi |
fi | fi | ||
Ligne 186: | Ligne 189: | ||
# " | # " | ||
file_env() { | file_env() { | ||
- | local var=" | + | |
- | local fileVar=" | + | local fileVar=" |
- | local def=" | + | local def=" |
- | if [ " | + | if [ " |
- | echo >&2 " | + | echo >&2 " |
- | exit 1 | + | exit 1 |
- | fi | + | fi |
- | local val=" | + | local val=" |
- | if [ " | + | if [ " |
- | val=" | + | val=" |
- | elif [ " | + | elif [ " |
- | val=" | + | val=" |
- | fi | + | fi |
- | export " | + | export " |
- | unset " | + | unset " |
} | } | ||
# see https:// | # see https:// | ||
_mongod_hack_have_arg() { | _mongod_hack_have_arg() { | ||
- | local checkArg=" | + | |
- | local arg | + | local arg |
- | for arg; do | + | for arg; do |
- | case " | + | case " |
- | " | + | " |
- | return 0 | + | return 0 |
- | ;; | + | ;; |
- | esac | + | esac |
- | done | + | done |
- | return 1 | + | return 1 |
} | } | ||
# _mongod_hack_get_arg_val ' | # _mongod_hack_get_arg_val ' | ||
_mongod_hack_get_arg_val() { | _mongod_hack_get_arg_val() { | ||
- | local checkArg=" | + | |
- | while [ " | + | while [ " |
- | local arg=" | + | local arg=" |
- | case " | + | case " |
- | " | + | " |
- | echo " | + | echo " |
- | return 0 | + | return 0 |
- | ;; | + | ;; |
- | " | + | " |
- | echo " | + | echo " |
- | return 0 | + | return 0 |
- | ;; | + | ;; |
- | esac | + | esac |
- | done | + | done |
- | return 1 | + | return 1 |
} | } | ||
declare -a mongodHackedArgs | declare -a mongodHackedArgs | ||
Ligne 238: | Ligne 241: | ||
# set -- " | # set -- " | ||
_mongod_hack_ensure_arg() { | _mongod_hack_ensure_arg() { | ||
- | local ensureArg=" | + | |
- | mongodHackedArgs=( " | + | mongodHackedArgs=( " |
- | if ! _mongod_hack_have_arg " | + | if ! _mongod_hack_have_arg " |
- | mongodHackedArgs+=( " | + | mongodHackedArgs+=( " |
- | fi | + | fi |
} | } | ||
# _mongod_hack_ensure_no_arg ' | # _mongod_hack_ensure_no_arg ' | ||
# set -- " | # set -- " | ||
_mongod_hack_ensure_no_arg() { | _mongod_hack_ensure_no_arg() { | ||
- | local ensureNoArg=" | + | |
- | mongodHackedArgs=() | + | mongodHackedArgs=() |
- | while [ " | + | while [ " |
- | local arg=" | + | local arg=" |
- | if [ " | + | if [ " |
- | continue | + | continue |
- | fi | + | fi |
- | mongodHackedArgs+=( " | + | mongodHackedArgs+=( " |
- | done | + | done |
} | } | ||
# _mongod_hack_ensure_no_arg ' | # _mongod_hack_ensure_no_arg ' | ||
# set -- " | # set -- " | ||
_mongod_hack_ensure_no_arg_val() { | _mongod_hack_ensure_no_arg_val() { | ||
- | local ensureNoArg=" | + | |
- | mongodHackedArgs=() | + | mongodHackedArgs=() |
- | while [ " | + | while [ " |
- | local arg=" | + | local arg=" |
- | case " | + | case " |
- | " | + | " |
- | shift # also skip the value | + | shift # also skip the value |
- | continue | + | continue |
- | ;; | + | ;; |
- | " | + | " |
- | # value is already included | + | # value is already included |
- | continue | + | continue |
- | ;; | + | ;; |
- | esac | + | esac |
- | mongodHackedArgs+=( " | + | mongodHackedArgs+=( " |
- | done | + | done |
} | } | ||
# _mongod_hack_ensure_arg_val ' | # _mongod_hack_ensure_arg_val ' | ||
# set -- " | # set -- " | ||
_mongod_hack_ensure_arg_val() { | _mongod_hack_ensure_arg_val() { | ||
- | local ensureArg=" | + | |
- | local ensureVal=" | + | local ensureVal=" |
- | _mongod_hack_ensure_no_arg_val " | + | _mongod_hack_ensure_no_arg_val " |
- | mongodHackedArgs+=( " | + | mongodHackedArgs+=( " |
} | } | ||
# _js_escape 'some " | # _js_escape 'some " | ||
_js_escape() { | _js_escape() { | ||
- | jq --null-input --arg ' | + | |
} | } | ||
Ligne 294: | Ligne 297: | ||
tempConfigFile=" | tempConfigFile=" | ||
_parse_config() { | _parse_config() { | ||
- | if [ -s " | + | |
- | return 0 | + | return 0 |
- | fi | + | fi |
- | local configPath | + | |
- | if configPath=" | + | if configPath=" |
- | # if --config is specified, parse it into a JSON file so we can remove a few problematic keys (especially SSL-related keys) | + | # if --config is specified, parse it into a JSON file so we can remove a few problematic keys (especially SSL-related keys) |
- | # see https:// | + | # see https:// |
- | mongo --norc --nodb --quiet --eval " | + | mongo --norc --nodb --quiet --eval " |
- | jq ' | + | jq ' |
- | return 0 | + | return 0 |
- | fi | + | fi |
- | return 1 | + | |
} | } | ||
dbPath= | dbPath= | ||
_dbPath() { | _dbPath() { | ||
- | if [ -n " | + | |
- | echo " | + | echo " |
- | return | + | return |
- | fi | + | fi |
- | if ! dbPath=" | + | |
- | if _parse_config " | + | if _parse_config " |
- | dbPath=" | + | dbPath=" |
- | fi | + | fi |
- | fi | + | fi |
- | if [ -z " | + | |
- | if _mongod_hack_have_arg --configsvr " | + | if _mongod_hack_have_arg --configsvr " |
- | _parse_config " | + | _parse_config " |
- | && clusterRole=" | + | && clusterRole=" |
- | && [ " | + | && [ " |
- | }; then | + | }; then |
- | # if running as config server, then the default dbpath is / | + | # if running as config server, then the default dbpath is / |
- | # https:// | + | # https:// |
- | dbPath=/ | + | dbPath=/ |
- | fi | + | fi |
- | fi | + | fi |
- | : " | + | |
- | echo " | + | |
} | } | ||
if [ " | if [ " | ||
- | file_env ' | + | |
- | file_env ' | + | file_env ' |
- | # pre-check a few factors to see if it's even worth bothering with initdb | + | # pre-check a few factors to see if it's even worth bothering with initdb |
- | shouldPerformInitdb= | + | shouldPerformInitdb= |
- | if [ " | + | if [ " |
- | # if we have a username/ | + | # if we have a username/ |
- | _mongod_hack_ensure_arg ' | + | _mongod_hack_ensure_arg ' |
- | set -- " | + | set -- " |
- | shouldPerformInitdb=' | + | shouldPerformInitdb=' |
- | elif [ " | + | elif [ " |
- | cat >&2 << | + | cat >&2 << |
- | error: missing ' | + | error: missing ' |
- | both must be specified for a user to be created | + | |
- | EOF | + | EOF |
- | exit 1 | + | exit 1 |
- | fi | + | fi |
- | if [ -z " | + | |
- | # if we've got any / | + | # if we've got any / |
- | for f in / | + | for f in / |
- | case " | + | case " |
- | *.sh|*.js) # this should match the set of files we check for below | + | *.sh|*.js) # this should match the set of files we check for below |
- | shouldPerformInitdb=" | + | shouldPerformInitdb=" |
- | break | + | break |
- | ;; | + | ;; |
- | esac | + | esac |
- | done | + | done |
- | fi | + | fi |
- | # check for a few known paths (to determine whether we've already initialized and should thus skip our initdb scripts) | + | |
- | if [ -n " | + | if [ -n " |
- | dbPath=" | + | dbPath=" |
- | for path in \ | + | for path in \ |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | ; do | + | ; do |
- | if [ -e " | + | if [ -e " |
- | shouldPerformInitdb= | + | shouldPerformInitdb= |
- | break | + | break |
- | fi | + | fi |
- | done | + | done |
- | fi | + | fi |
- | if [ -n " | + | |
- | mongodHackedArgs=( " | + | mongodHackedArgs=( " |
- | if _parse_config " | + | if _parse_config " |
- | _mongod_hack_ensure_arg_val --config " | + | _mongod_hack_ensure_arg_val --config " |
- | fi | + | fi |
- | _mongod_hack_ensure_arg_val --bind_ip 127.0.0.1 " | + | _mongod_hack_ensure_arg_val --bind_ip 127.0.0.1 " |
- | _mongod_hack_ensure_arg_val --port 27017 " | + | _mongod_hack_ensure_arg_val --port 27017 " |
- | _mongod_hack_ensure_no_arg --bind_ip_all " | + | _mongod_hack_ensure_no_arg --bind_ip_all " |
- | # remove " | + | |
- | # https:// | + | # https:// |
- | _mongod_hack_ensure_no_arg --auth " | + | _mongod_hack_ensure_no_arg --auth " |
- | if [ " | + | if [ " |
- | _mongod_hack_ensure_no_arg_val --replSet " | + | _mongod_hack_ensure_no_arg_val --replSet " |
- | fi | + | fi |
- | sslMode=" | + | |
- | _mongod_hack_ensure_arg_val --sslMode " | + | _mongod_hack_ensure_arg_val --sslMode " |
- | if stat "/ | + | |
- | # https:// | + | # https:// |
- | # https:// | + | # https:// |
- | _mongod_hack_ensure_arg_val --logpath "/ | + | _mongod_hack_ensure_arg_val --logpath "/ |
- | else | + | else |
- | initdbLogPath=" | + | initdbLogPath=" |
- | echo >&2 " | + | echo >&2 " |
- | _mongod_hack_ensure_arg_val --logpath " | + | _mongod_hack_ensure_arg_val --logpath " |
- | fi | + | fi |
- | _mongod_hack_ensure_arg --logappend " | + | _mongod_hack_ensure_arg --logappend " |
- | pidfile=" | + | |
- | rm -f " | + | rm -f " |
- | _mongod_hack_ensure_arg_val --pidfilepath " | + | _mongod_hack_ensure_arg_val --pidfilepath " |
- | " | + | |
- | mongo=( mongo --host 127.0.0.1 --port 27017 --quiet ) | + | |
- | # check to see that our " | + | |
- | # https:// | + | # https:// |
- | tries=30 | + | tries=30 |
- | while true; do | + | while true; do |
- | if ! { [ -s " | + | if ! { [ -s " |
- | # bail ASAP if " | + | # bail ASAP if " |
- | echo >& | + | echo >& |
- | echo >&2 " | + | echo >&2 " |
- | echo >& | + | echo >& |
- | exit 1 | + | exit 1 |
- | fi | + | fi |
- | if " | + | if " |
- | # success! | + | # success! |
- | break | + | break |
- | fi | + | fi |
- | (( tries-- )) | + | (( tries-- )) |
- | if [ " | + | if [ " |
- | echo >& | + | echo >& |
- | echo >&2 " | + | echo >&2 " |
- | echo >& | + | echo >& |
- | exit 1 | + | exit 1 |
- | fi | + | fi |
- | sleep 1 | + | sleep 1 |
- | done | + | done |
- | if [ " | + | |
- | rootAuthDatabase=' | + | rootAuthDatabase=' |
- | " | + | |
- | db.createUser({ | + | db.createUser({ |
- | user: $(_js_escape " | + | user: $(_js_escape " |
- | pwd: $(_js_escape " | + | pwd: $(_js_escape " |
- | roles: [ { role: ' | + | roles: [ { role: ' |
- | }) | + | }) |
- | EOJS | + | EOJS |
- | fi | + | fi |
- | export MONGO_INITDB_DATABASE=" | + | |
- | echo | + | |
- | for f in / | + | for f in / |
- | case " | + | case " |
- | *.sh) echo "$0: running $f"; . " | + | *.sh) echo "$0: running $f"; . " |
- | *.js) echo "$0: running $f"; " | + | *.js) echo "$0: running $f"; " |
- | *) echo "$0: ignoring $f" ;; | + | *) echo "$0: ignoring $f" ;; |
- | esac | + | esac |
- | echo | + | echo |
- | done | + | done |
- | " | + | |
- | rm -f " | + | rm -f " |
- | echo | + | |
- | echo ' | + | echo ' |
- | echo | + | echo |
- | fi | + | fi |
- | # MongoDB 3.6+ defaults to localhost-only binding | + | |
- | if mongod --help 2>&1 | grep -q -- --bind_ip_all; | + | if mongod --help 2>&1 | grep -q -- --bind_ip_all; |
- | haveBindIp= | + | haveBindIp= |
- | if _mongod_hack_have_arg --bind_ip " | + | if _mongod_hack_have_arg --bind_ip " |
- | haveBindIp=1 | + | haveBindIp=1 |
- | elif _parse_config " | + | elif _parse_config " |
- | haveBindIp=1 | + | haveBindIp=1 |
- | fi | + | fi |
- | if [ -z " | + | if [ -z " |
- | # so if no " | + | # so if no " |
- | set -- " | + | set -- " |
- | fi | + | fi |
- | fi | + | fi |
- | unset " | + | |
fi | fi | ||
Ligne 500: | Ligne 503: | ||
exec " | exec " | ||
- | </file> | + | </code> |
Examinons chaque commande dans le Dockerfile : | Examinons chaque commande dans le Dockerfile : | ||
Ligne 546: | Ligne 549: | ||
wget -O / | wget -O / | ||
export GNUPGHOME=" | export GNUPGHOME=" | ||
- | gpg --batch --keyserver | + | gpg --batch --keyserver |
gpg --batch --verify / | gpg --batch --verify / | ||
command -v gpgconf && gpgconf --kill all || :; \ | command -v gpgconf && gpgconf --kill all || :; \ | ||
Ligne 565: | Ligne 568: | ||
export GNUPGHOME=" | export GNUPGHOME=" | ||
for key in $GPG_KEYS; do \ | for key in $GPG_KEYS; do \ | ||
- | gpg --batch --keyserver | + | gpg --batch --keyserver |
done; \ | done; \ | ||
gpg --batch --export $GPG_KEYS > / | gpg --batch --export $GPG_KEYS > / | ||
Ligne 595: | Ligne 598: | ||
RUN ["/ | RUN ["/ | ||
- | <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' | **Important** : La commande RUN est utilisée pour exécuter une commande passée en argument lors de la compilation de l' | ||
</ | </ | ||
Ligne 646: | Ligne 649: | ||
Il est possible d' | Il est possible d' | ||
- | <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' | **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' | ||
</ | </ | ||
Ligne 702: | Ligne 705: | ||
Ce fichier finit par " | Ce fichier finit par " | ||
- | <WRAP center round important> | + | <WRAP center round important |
**Important** - Notez que la compilation d'une image se fait à l' | **Important** - Notez que la compilation d'une image se fait à l' | ||
</ | </ | ||
Ligne 739: | Ligne 742: | ||
< | < | ||
- | root@debian9:~/mongodb# docker build . | + | root@debian11:~/mongodb# docker build . |
+ | [+] Building 56.9s (15/15) FINISHED | ||
+ | => [internal] load .dockerignore | ||
+ | => => transferring context: 2B | ||
+ | => [internal] load build definition from Dockerfile | ||
+ | => => transferring dockerfile: 3.55kB | ||
+ | => [internal] load metadata for docker.io/ | ||
+ | => [internal] load build context | ||
+ | => => transferring context: 42B 0.0s | ||
+ | => [ 1/10] FROM docker.io/ | ||
+ | => CACHED [ 2/10] RUN groupadd -r mongodb && useradd -r -g mongodb mongodb | ||
+ | => CACHED [ 3/10] RUN set -eux; apt-get update; | ||
+ | => [ 4/10] RUN set -ex; | ||
+ | => [ 5/10] RUN mkdir / | ||
+ | => [ 6/10] RUN set -ex; export GNUPGHOME=" | ||
+ | => [ 7/10] RUN echo "deb http:// | ||
+ | => [ 8/10] RUN set -x && apt-get update | ||
+ | => [ 9/10] RUN mkdir -p /data/db / | ||
+ | => [10/10] COPY docker-entrypoint.sh / | ||
+ | => exporting to image 2.6s | ||
+ | => => exporting layers | ||
+ | => => writing image sha256: | ||
</ | </ | ||
Ligne 745: | Ligne 769: | ||
< | < | ||
- | root@debian9:~/mongodb# docker images | + | root@debian11:~/mongodb# docker images |
- | REPOSITORY | + | REPOSITORY |
- | < | + | < |
- | i2tch/ | + | ittraining/ |
- | nginx latest | + | ubuntu |
- | centos | + | nginx |
- | ubuntu | + | hello-world |
- | ubuntu | + | centos |
- | hello-world | + | |
</ | </ | ||
Ligne 759: | Ligne 782: | ||
< | < | ||
- | root@debian9:~/mongodb# docker tag 3bf2 i2tch/ | + | root@debian11:~/mongodb# docker tag 72f i2tch/ |
- | root@debian9:~/mongodb# docker images | + | |
- | REPOSITORY | + | root@debian11:~/mongodb# docker images |
- | i2tch/ | + | REPOSITORY |
- | i2tch/ | + | i2tch/ |
- | nginx latest | + | ittraining/ |
- | centos | + | ubuntu |
- | ubuntu | + | nginx |
- | ubuntu | + | hello-world |
- | hello-world | + | centos |
</ | </ | ||
Ligne 774: | Ligne 797: | ||
< | < | ||
- | root@debian9:~/mongodb# docker run -d --name mongo1 i2tch/ | + | root@debian11:~/mongodb# docker run -d --name mongo1 i2tch/ |
- | bdb4bc0f81de8b5821f20d8609b9640abaaae7b4a7577c42b78d4bd34617d211 | + | 3c578ea2a0428a07b60dac3b63d806351dffa2bb05224bcf7d12f1189766f38e |
- | docker: Error response from daemon: | + | docker: Error response from daemon: |
- | root@debian9:~/mongodb# ls -l | + | |
+ | root@debian11:~/mongodb# ls -l | ||
total 16 | total 16 | ||
- | -rw-r--r-- 1 root root 10971 avril 9 13:56 docker-entrypoint.sh | + | -rw-r--r-- 1 root root 10971 Dec 10 16:57 docker-entrypoint.sh |
- | -rw-r--r-- 1 root root | + | -rw-r--r-- 1 root root |
</ | </ | ||
- | <WRAP center round important> | + | <WRAP center round important |
- | **Important** - Notez que le fichier docker-entrypoint.sh n'était | + | **Important** - Notez que le fichier docker-entrypoint.sh n'est pas exécutable ! |
</ | </ | ||
Ligne 790: | Ligne 814: | ||
< | < | ||
- | root@debian9:~/mongodb# docker rm mongo1 | + | root@debian11:~/mongodb# docker rm mongo1 |
mongo1 | mongo1 | ||
- | root@debian9:~/mongodb# chmod +x docker-entrypoint.sh | + | |
- | root@debian9:~/mongodb# docker build . | + | root@debian11:~/mongodb# chmod +x docker-entrypoint.sh |
- | Sending | + | |
- | Step 1/22 : FROM ubuntu: | + | root@debian11:~/mongodb# docker build . |
- | ---> 94e814e2efa8 | + | [+] Building 0.8s (15/15) FINISHED |
- | Step 2/22 : RUN groupadd -r mongodb && useradd -r -g mongodb mongodb | + | => [internal] load build definition from Dockerfile |
- | ---> Using cache | + | => => transferring dockerfile: 3.55kB |
- | | + | => [internal] load .dockerignore |
- | Step 3/22 : RUN set -eux; apt-get update; | + | => => transferring |
- | ---> Using cache | + | => [internal] load metadata for docker.io/library/ |
- | ---> adc57da1b19f | + | => [ 1/10] FROM docker.io/ |
- | Step 4/22 : ENV GOSU_VERSION 1.11 | + | => [internal] load build context |
- | ---> Using cache | + | => => transferring context: 11.02kB |
- | ---> 038e7de870b7 | + | => CACHED [ 2/10] RUN groupadd -r mongodb && useradd -r -g mongodb mongodb |
- | Step 5/22 : ENV JSYAML_VERSION 3.13.0 | + | => CACHED [ 3/10] RUN set -eux; apt-get update; |
- | ---> Using cache | + | => CACHED [ 4/10] RUN set -ex; |
- | ---> 3bf216d921d6 | + | => CACHED [ 5/10] RUN mkdir / |
- | ... | + | => CACHED [ 6/10] RUN set -ex; export GNUPGHOME=" |
- | Removing intermediate container a98ae692fe1f | + | => CACHED [ 7/10] RUN echo "deb http:// |
- | ---> 04c2e98927c3 | + | => CACHED [ 8/10] RUN set -x && apt-get update |
- | Step 17/22 : RUN mkdir -p /data/db / | + | => CACHED [ 9/10] RUN mkdir -p /data/db / |
- | ---> Running in d0f5bee34571 | + | => [10/10] COPY docker-entrypoint.sh / |
- | Removing intermediate container d0f5bee34571 | + | => exporting to image 0.1s |
- | | + | => => exporting layers |
- | Step 18/22 : VOLUME /data/db / | + | => => writing image sha256:56e5b1fb4284e2474392238ee5f91a5d27d9a4a43fa15f655136ae0283d269c2 |
- | | + | |
- | Removing intermediate container c7626528a9b9 | + | |
- | | + | |
- | Step 19/22 : COPY docker-entrypoint.sh / | + | |
- | ---> eedfd53da0f8 | + | |
- | Step 20/22 : ENTRYPOINT [" | + | |
- | ---> 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 [" | + | |
- | | + | |
- | Removing intermediate container 458d6f15cdf2 | + | |
- | | + | |
- | Successfully built 12e00099ca8d | + | |
- | root@debian9: | + | |
</ | </ | ||
- | <WRAP center round important> | + | <WRAP center round important |
- | **Important** - Notez ici les lignes **Using cache**. Il est cependant possible de ne pas utiliser le cache en stipulant **--no-cache**. Notez aussi l' | + | **Important** - Notez ici les lignes **CACHED**. Il est cependant possible de ne pas utiliser le cache en stipulant **--no-cache**. Notez aussi l' |
</ | </ | ||
Ligne 845: | Ligne 850: | ||
< | < | ||
- | root@debian9:~/mongodb# docker images | + | root@debian11:~/mongodb# docker images |
- | REPOSITORY | + | REPOSITORY |
- | < | + | < |
- | i2tch/ | + | i2tch/ |
- | i2tch/ | + | ittraining/ |
- | nginx latest | + | ubuntu |
- | centos | + | nginx |
- | ubuntu | + | hello-world |
- | ubuntu | + | centos |
- | hello-world | + | |
- | root@debian9:~/mongodb# docker tag 12e0 i2tch/ | + | root@debian11:~/mongodb# docker tag 56e i2tch/ |
- | root@debian9:~/mongodb# docker images | + | |
- | REPOSITORY | + | root@debian11:~/mongodb# docker images |
- | i2tch/ | + | REPOSITORY |
- | i2tch/ | + | i2tch/ |
- | i2tch/ | + | i2tch/ |
- | nginx latest | + | ittraining/ |
- | centos | + | ubuntu |
- | ubuntu | + | nginx |
- | ubuntu | + | hello-world |
- | hello-world | + | centos |
</ | </ | ||
Ligne 871: | Ligne 876: | ||
< | < | ||
- | root@debian9:~/mongodb# docker run -d --name mongo2 i2tch/ | + | root@debian11:~/mongodb# docker run -d --name mongo2 i2tch/ |
- | e91a055283f4d67cbd91d11bb3faa6f67925893cb18f9cc25023e72e0f7ed85a | + | 880733c6bdc33a9a8fa6ae171e977cf745ea9a1b9cfc914992a2d0d3f8cd9d39 |
</ | </ | ||
Ligne 878: | Ligne 883: | ||
< | < | ||
- | root@debian9:~/mongodb# docker ps | + | root@debian11:~/mongodb# docker ps |
- | CONTAINER ID IMAGE | + | CONTAINER ID |
- | e91a055283f4 | + | 880733c6bdc3 |
- | d2ddb4f8ca8a | + | 885f75b6aa57 |
- | c080793965de | + | 04d910a3c93d |
</ | </ | ||
Ligne 888: | Ligne 893: | ||
< | < | ||
- | root@debian9:~/mongodb# docker inspect mongo2 | grep IP | + | root@debian11:~/mongodb# docker inspect mongo2 | grep IP |
" | " | ||
" | " | ||
Ligne 904: | Ligne 909: | ||
" | " | ||
" | " | ||
- | root@debian9: | + | |
- | root@debian9:~/mongodb# mongo --host 172.17.0.4 | + | root@debian11:~/mongodb# mongo --host 172.17.0.4 |
- | MongoDB shell version v4.0.8 | + | MongoDB shell version v4.0.28 |
connecting to: mongodb:// | connecting to: mongodb:// | ||
- | Implicit session: session { " | + | Implicit session: session { " |
MongoDB server version: 4.1.9 | MongoDB server version: 4.1.9 | ||
WARNING: shell and server versions do not match | WARNING: shell and server versions do not match | ||
Server has startup warnings: | Server has startup warnings: | ||
- | 2019-04-09T17:50:12.635+0000 I STORAGE | + | 2023-12-10T16:16:13.395+0000 I STORAGE |
- | 2019-04-09T17:50:12.636+0000 I STORAGE | + | 2023-12-10T16:16:13.395+0000 I STORAGE |
- | 2019-04-09T17:50:12.636+0000 I STORAGE | + | 2023-12-10T16:16:13.395+0000 I STORAGE |
- | 2019-04-09T17:50:13.458+0000 I CONTROL | + | 2023-12-10T16:16:14.255+0000 I CONTROL |
- | 2019-04-09T17:50:13.459+0000 I CONTROL | + | 2023-12-10T16:16:14.255+0000 I CONTROL |
- | 2019-04-09T17:50:13.459+0000 I CONTROL | + | 2023-12-10T16:16:14.255+0000 I CONTROL |
- | 2019-04-09T17:50:13.459+0000 I CONTROL | + | 2023-12-10T16:16:14.255+0000 I CONTROL |
- | 2019-04-09T17:50:13.459+0000 I CONTROL | + | 2023-12-10T16:16:14.255+0000 I CONTROL |
- | 2019-04-09T17:50:13.459+0000 I CONTROL | + | 2023-12-10T16:16:14.255+0000 I CONTROL |
- | 2019-04-09T17:50:13.460+0000 I CONTROL | + | 2023-12-10T16:16:14.255+0000 I CONTROL |
+ | 2023-12-10T16: | ||
+ | 2023-12-10T16: | ||
+ | 2023-12-10T16: | ||
+ | 2023-12-10T16: | ||
--- | --- | ||
Enable MongoDB' | Enable MongoDB' | ||
Ligne 936: | Ligne 945: | ||
> exit | > exit | ||
bye | bye | ||
- | root@debian9:~/mongodb# | + | root@debian11:~/mongodb# |
- | </ | + | |
- | + | ||
- | Notez que lors de la compilation de l' | + | |
- | + | ||
- | < | + | |
- | root@debian9: | + | |
- | REPOSITORY | + | |
- | i2tch/ | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | i2tch/ | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | i2tch/ | + | |
- | < | + | |
- | < | + | |
- | nginx | + | |
- | centos | + | |
- | ubuntu | + | |
- | ubuntu | + | |
- | hello-world | + | |
</ | </ | ||
Ligne 980: | Ligne 955: | ||
< | < | ||
- | root@debian9:~/mongodb# mkdir ~/ | + | root@debian11:~/mongodb# mkdir ~/ |
- | root@debian9:~/mongodb# cd ~/ | + | root@debian11:~/mongodb# cd ~/ |
- | root@debian9: | + | root@debian11: |
</ | </ | ||
Ligne 988: | Ligne 963: | ||
< | < | ||
- | root@debian9: | + | root@debian11: |
- | root@debian9: | + | |
+ | root@debian11: | ||
#!/bin/bash | #!/bin/bash | ||
if [ -z " | if [ -z " | ||
- | echo "La variable myVariable | + | |
- | return 1 | + | return 1 |
fi | fi | ||
while true; | while true; | ||
do | do | ||
- | echo $1 \($(date +%H: | + | |
- | sleep " | + | sleep " |
done | done | ||
</ | </ | ||
Ligne 1006: | Ligne 982: | ||
< | < | ||
- | root@debian9: | + | root@debian11: |
- | salut (20:04:39) | + | Hello! |
- | salut (20:04:42) | + | Hello! |
- | salut (20:04:45) | + | Hello! |
- | salut (20:04:48) | + | Hello! |
- | salut (20:04:51) | + | Hello! |
^C | ^C | ||
- | root@debian9: | + | root@debian11: |
</ | </ | ||
Ligne 1019: | Ligne 995: | ||
< | < | ||
- | root@debian9: | + | root@debian11: |
</ | </ | ||
Ligne 1025: | Ligne 1001: | ||
< | < | ||
- | root@debian9: | + | root@debian11: |
- | root@debian9: | + | |
+ | root@debian11: | ||
FROM centos: | FROM centos: | ||
- | MAINTAINER | + | MAINTAINER |
COPY myEntrypoint.sh / | COPY myEntrypoint.sh / | ||
ENV myVariable 3 | ENV myVariable 3 | ||
Ligne 1038: | Ligne 1015: | ||
< | < | ||
- | root@debian9: | + | root@debian11: |
- | Sending build context to Docker daemon | + | [+] Building 0.8s (7/7) FINISHED |
- | Step 1/6 : FROM centos: | + | => [internal] load .dockerignore |
- | ---> 9f38484d220f | + | => => transferring context: 2B 0.0s |
- | Step 2/6 : MAINTAINER i2tch " | + | => [internal] load build definition from Dockerfile |
- | ---> Running in 02c700ed04da | + | => => transferring dockerfile: 211B 0.0s |
- | Removing intermediate container 02c700ed04da | + | => [internal] load metadata for docker.io/library/ |
- | ---> 4274107d52e2 | + | => [internal] load build context |
- | Step 3/6 : COPY myEntrypoint.sh / | + | => => transferring context: 224B 0.0s |
- | ---> 7a3923372768 | + | => [1/2] FROM docker.io/ |
- | Step 4/6 : ENV myVariable 3 | + | |
- | ---> Running in 3288bf6291ad | + | => exporting to image 0.1s |
- | Removing intermediate container 3288bf6291ad | + | => => exporting layers |
- | ---> 3edb630c1511 | + | => => writing image sha256:c5a41438d278439fac2cd65d53d87cabc5c771dd9b99be1913ce049024eba961 |
- | Step 5/6 : ENTRYPOINT | + | => => naming to docker.io/i2tch/ |
- | ---> Running in 8dcba2c41520 | + | |
- | Removing intermediate container 8dcba2c41520 | + | |
- | ---> 11962052539c | + | |
- | Step 6/6 : CMD [" | + | |
- | ---> Running in f891fbcfaad0 | + | |
- | Removing intermediate container f891fbcfaad0 | + | |
- | ---> 7925ba23abb2 | + | |
- | Successfully built 7925ba23abb2 | + | |
- | Successfully tagged | + | |
</ | </ | ||
Ligne 1067: | Ligne 1035: | ||
< | < | ||
- | root@debian9: | + | root@debian11: |
- | mycommand (18:07:12) | + | mycommand (17:05:57) |
- | mycommand (18:07:15) | + | mycommand (17:06:00) |
- | mycommand (18:07:18) | + | mycommand (17:06:03) |
- | mycommand (18:07:21) | + | ^Cmycommand (17:06:06) |
- | ^Cmycommand (18:07:22) | + | mycommand (17:06:09) |
- | mycommand (18:07:25) | + | mycommand (17:06:12) |
- | mycommand (18:07:28) | + | |
^P^Q | ^P^Q | ||
- | root@debian9: | + | root@debian11: |
</ | </ | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **Important** - Notez que **^C** n'a aucun effet. Pour se détacher du conteneur il convient d' | ||
+ | </ | ||
Constatez que le conteneur est toujours en cours de fonctionnement : | Constatez que le conteneur est toujours en cours de fonctionnement : | ||
< | < | ||
- | root@debian9: | + | root@debian11: |
- | CONTAINER ID IMAGE | + | CONTAINER ID |
- | 140ecfdd80b7 | + | 97fe360bb1d6 |
- | b3380889eb75 | + | 880733c6bdc3 |
- | d2ddb4f8ca8a | + | 885f75b6aa57 |
- | c080793965de | + | 04d910a3c93d |
- | root@debian9:~/myDocker# | + | |
- | root@debian9: | + | root@debian11: |
- | mycommand (18:08:25) | + | mycommand (17:10:30) |
- | mycommand (18:08:28) | + | mycommand (17:10:33) |
- | mycommand (18:08:31) | + | mycommand (17:10:36) |
- | mycommand (18:08:34) | + | mycommand (17:10:39) |
- | mycommand (18:08:37) | + | mycommand (17:10:42) |
- | mycommand (18:08:40) | + | mycommand (17:10:45) |
- | mycommand (18:08:43) | + | mycommand (17:10:48) |
- | mycommand (18:08:46) | + | mycommand (17:10:51) |
- | mycommand (18:08:49) | + | mycommand (17:10:54) |
- | mycommand (18:08:52) | + | mycommand (17:10:57) |
</ | </ | ||
Ligne 1105: | Ligne 1076: | ||
< | < | ||
- | root@debian9: | + | root@debian11: |
myDocker | myDocker | ||
- | root@debian9: | + | |
- | CONTAINER ID IMAGE | + | root@debian11: |
- | b3380889eb75 | + | CONTAINER ID |
- | d2ddb4f8ca8a | + | 880733c6bdc3 |
- | c080793965de | + | 885f75b6aa57 |
+ | 04d910a3c93d | ||
</ | </ | ||
Ligne 1117: | Ligne 1089: | ||
< | < | ||
- | root@debian9: | + | root@debian11: |
myDocker | myDocker | ||
- | root@debian9: | + | |
- | CONTAINER ID IMAGE | + | root@debian11: |
- | 140ecfdd80b7 | + | CONTAINER ID |
- | b3380889eb75 | + | 97fe360bb1d6 |
- | d2ddb4f8ca8a | + | 880733c6bdc3 |
- | c080793965de | + | 885f75b6aa57 |
+ | 04d910a3c93d | ||
</ | </ | ||
Ligne 1130: | Ligne 1103: | ||
< | < | ||
- | root@debian9: | + | root@debian11: |
myDocker | myDocker | ||
- | root@debian9: | + | |
- | CONTAINER ID IMAGE | + | root@debian11: |
- | 140ecfdd80b7 | + | CONTAINER ID |
- | b3380889eb75 | + | 97fe360bb1d6 |
- | d2ddb4f8ca8a | + | 880733c6bdc3 |
- | c080793965de | + | 885f75b6aa57 |
+ | 04d910a3c93d | ||
</ | </ | ||
Ligne 1143: | Ligne 1117: | ||
< | < | ||
- | root@debian9: | + | root@debian11: |
myDocker | myDocker | ||
- | root@debian9: | + | |
- | CONTAINER ID IMAGE | + | root@debian11: |
- | 140ecfdd80b7 | + | CONTAINER ID |
- | b3380889eb75 | + | 97fe360bb1d6 |
- | d2ddb4f8ca8a | + | 880733c6bdc3 |
- | c080793965de | + | 885f75b6aa57 |
+ | 04d910a3c93d | ||
</ | </ | ||
Ligne 1156: | Ligne 1131: | ||
< | < | ||
- | root@debian9: | + | root@debian11: |
myDocker | myDocker | ||
- | root@debian9: | + | |
- | 0cf8c8c1bdf4cb05d9852900ecdf171ad9abad0fce29a9f040d5d8436285db65 | + | root@debian11: |
- | root@debian9: | + | fd5ac836f674fe0bf7b5056e851cd15e4762a5e41b05e00d384bede5234e1f5f |
- | Up and Running (18:13:33) | + | |
- | Up and Running (18:13:36) | + | root@debian11: |
- | Up and Running (18:13:39) | + | Up and Running (17:14:23) |
- | Up and Running (18:13:42) | + | Up and Running (17: |
- | root@debian9: | + | Up and Running (17:14:29) |
+ | Up and Running (17:14:32) | ||
+ | Up and Running (17:14:35) | ||
+ | Up and Running (17:14:38) | ||
+ | root@debian11: | ||
</ | </ | ||
Ligne 1171: | Ligne 1150: | ||
< | < | ||
- | root@debian9: | + | root@debian11: |
myDocker | myDocker | ||
- | root@debian9: | + | |
- | fbbe3b48c63310e37a3bad5fc962361c39c045a107f47980614efd6b2e8d3981 | + | root@debian11: |
- | root@debian9: | + | a9e02a8bb39df9d5c84fc1d58643bc38c228b0562731792e2356a801b50a9a14 |
- | mycommand (18:14:47) | + | |
- | mycommand (18: | + | root@debian11: |
- | mycommand (18: | + | mycommand (17:15:35) |
- | mycommand (18: | + | mycommand (17:15:36) |
- | mycommand (18:14:51) | + | mycommand (17:15:37) |
- | mycommand (18:14:52) | + | mycommand (17:15:38) |
- | mycommand (18:14:53) | + | mycommand (17:15:39) |
- | mycommand (18:14:54) | + | mycommand (17:15:40) |
- | mycommand (18:14:55) | + | mycommand (17:15:41) |
- | mycommand (18:14:56) | + | root@debian11: |
- | mycommand (18:14:57) | + | |
- | root@debian9: | + | |
</ | </ | ||
Ligne 1197: | Ligne 1174: | ||
< | < | ||
- | root@debian9: | + | root@debian11: |
- | root@debian9:~# mkdir bestp | + | |
- | root@debian9:~# cd bestp | + | root@debian11:~# mkdir bestp |
- | root@debian9:~/bestp# vi Dockerfile | + | |
- | root@debian9:~/bestp# cat Dockerfile | + | root@debian11:~# cd bestp |
+ | |||
+ | root@debian11:~/bestp# vi Dockerfile | ||
+ | |||
+ | root@debian11:~/bestp# cat Dockerfile | ||
FROM ubuntu: | FROM ubuntu: | ||
RUN date +%N > /tmp/moment | RUN date +%N > /tmp/moment | ||
Ligne 1210: | Ligne 1191: | ||
Le fichier Dokerfile contient une opération non idempotente. | Le fichier Dokerfile contient une opération non idempotente. | ||
- | <WRAP center round important> | + | <WRAP center round important |
**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. | **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. | ||
</ | </ | ||
Ligne 1217: | Ligne 1198: | ||
< | < | ||
- | root@debian9:~/bestp# docker build -t testcache . | + | root@debian11:~/bestp# docker build -t testcache . |
- | Sending | + | [+] Building 0.9s (6/6) FINISHED |
- | Step 1/4 : FROM ubuntu: | + | => [internal] load build definition from Dockerfile |
- | ---> 94e814e2efa8 | + | => => transferring dockerfile: 123B 0.0s |
- | Step 2/4 : RUN date +%N > / | + | => [internal] load .dockerignore |
- | ---> Running in 6c8c677c1549 | + | => => transferring |
- | Removing intermediate container 6c8c677c1549 | + | => [internal] load metadata for docker.io/library/ |
- | ---> 66c3c88c57bb | + | => [1/2] FROM docker.io/ |
- | Step 3/4 : ENTRYPOINT [" | + | => [2/2] RUN date +%N > / |
- | ---> Running in e9658e591172 | + | => exporting to image 0.1s |
- | Removing intermediate container e9658e591172 | + | => => exporting layers |
- | ---> 81cb68241ec9 | + | => => writing image sha256:842ab4a40890a1b5fe7a3af5a41513c6edd5fd2da503b82c375f350671b62707 |
- | Step 4/4 : CMD ["/ | + | => => naming to docker.io/ |
- | ---> Running in 48974dc12faa | + | |
- | Removing intermediate container 48974dc12faa | + | |
- | ---> c55a42a18572 | + | |
- | Successfully built c55a42a18572 | + | |
- | Successfully tagged | + | |
- | root@debian9: | + | |
</ | </ | ||
Ligne 1241: | Ligne 1216: | ||
< | < | ||
- | root@debian9:~/bestp# docker run --name test1 -it testcache | + | root@debian11:~/bestp# docker run --name test1 -it testcache |
- | 369009216 | + | 771723987 |
</ | </ | ||
Ligne 1248: | Ligne 1223: | ||
< | < | ||
- | root@debian9:~/bestp# docker rm test1 | + | root@debian11:~/bestp# docker rm test1 |
test1 | test1 | ||
- | root@debian9:~/bestp# docker build -t testcache . | + | |
- | Sending build context | + | root@debian11:~/bestp# docker build -t testcache . |
- | Step 1/4 : FROM ubuntu: | + | [+] Building 0.3s (6/6) FINISHED |
- | ---> 94e814e2efa8 | + | => [internal] load .dockerignore |
- | Step 2/4 : RUN date +%N > / | + | => => transferring |
- | ---> Using cache | + | => [internal] load build definition from Dockerfile |
- | ---> 66c3c88c57bb | + | => => transferring dockerfile: 123B 0.0s |
- | Step 3/4 : ENTRYPOINT [" | + | => [internal] load metadata for docker.io/library/ |
- | ---> Using cache | + | => [1/2] FROM docker.io/ |
- | ---> 81cb68241ec9 | + | => CACHED [2/2] RUN date +%N > / |
- | Step 4/4 : CMD ["/ | + | => exporting to image 0.0s |
- | ---> Using cache | + | => => exporting layers |
- | ---> c55a42a18572 | + | => => writing image sha256:842ab4a40890a1b5fe7a3af5a41513c6edd5fd2da503b82c375f350671b62707 |
- | Successfully built c55a42a18572 | + | => => naming to docker.io/ |
- | Successfully tagged | + | |
- | root@debian9: | + | |
</ | </ | ||
Ligne 1271: | Ligne 1244: | ||
< | < | ||
- | root@debian9:~/bestp# docker run --name test1 -it testcache | + | root@debian11:~/bestp# docker run --name test1 -it testcache |
- | 369009216 | + | 771723987 |
</ | </ | ||
- | <WRAP center round important> | + | <WRAP center round important |
**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' | **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' | ||
</ | </ | ||
Ligne 1282: | Ligne 1255: | ||
< | < | ||
- | root@debian9:~/bestp# vi Dockerfile | + | root@debian11:~/bestp# vi Dockerfile |
- | root@debian9:~/bestp# cat Dockerfile | + | |
+ | root@debian11:~/bestp# cat Dockerfile | ||
FROM ubuntu: | FROM ubuntu: | ||
RUN date +%N > /tmp/moment \ | RUN date +%N > /tmp/moment \ | ||
Ligne 1294: | Ligne 1268: | ||
< | < | ||
- | root@debian9:~/bestp# docker rm test1 | + | root@debian11:~/bestp# docker rm test1 |
test1 | test1 | ||
- | root@debian9:~/bestp# docker build -t testcache . | + | |
- | Sending build context | + | root@debian11:~/bestp# docker build -t testcache . |
- | Step 1/4 : FROM ubuntu: | + | [+] Building 0.7s (6/6) FINISHED |
- | ---> 94e814e2efa8 | + | => [internal] load .dockerignore |
- | Step 2/4 : RUN date +%N > / | + | => => transferring |
- | ---> Running in 3d2a5cee6ac8 | + | => [internal] load build definition from Dockerfile |
- | Removing intermediate container 3d2a5cee6ac8 | + | => => transferring dockerfile: 159B 0.0s |
- | ---> 75d0498a9676 | + | => [internal] load metadata for docker.io/library/ |
- | Step 3/4 : ENTRYPOINT [" | + | => CACHED [1/2] FROM docker.io/ |
- | ---> Running in 88c0cec68659 | + | => [2/2] RUN date +%N > / |
- | Removing intermediate container 88c0cec68659 | + | => exporting to image 0.1s |
- | ---> 2aee524c8da4 | + | => => exporting layers |
- | Step 4/4 : CMD ["/ | + | => => writing image sha256:5a36b1c7ec76e7bde962c41f5f5dcc11ae0ce3968e4953fbababcc8b7b282dab |
- | ---> Running in 82d2162bb701 | + | => => naming to docker.io/ |
- | Removing intermediate container 82d2162bb701 | + | |
- | ---> a54c4af89994 | + | |
- | Successfully built a54c4af89994 | + | |
- | Successfully tagged | + | |
</ | </ | ||
Ligne 1319: | Ligne 1289: | ||
< | < | ||
- | root@debian9:~/bestp# docker run --name test1 -it testcache | + | root@debian11:~/bestp# docker run --name test1 -it testcache |
- | 746997174 | + | 063819144 |
</ | </ | ||
Ligne 1330: | Ligne 1300: | ||
< | < | ||
- | root@debian9:~/bestp# cd .. | + | root@debian11:~/bestp# cd .. |
- | root@debian9:~# docker run -d --name registry -p 88:5000 registry:2.0 | + | |
- | Unable to find image ' | + | root@debian11:~# docker run -d --name registry -p 88:5000 registry:latest |
- | 2.0: Pulling from library/ | + | Unable to find image ' |
- | 4d2e9ae40c41: Pull complete | + | latest: Pulling from library/ |
- | a3ed95caeb02: Pull complete | + | c926b61bad3b: Pull complete |
- | 7c8152785df5: Pull complete | + | 5501dced60f8: Pull complete |
- | 8b04aafd7cd8: Pull complete | + | e875fe5e6b9c: Pull complete |
- | c97c75d2d42e: | + | 21f4bf2f86f9: Pull complete |
- | 4b3ef98bba76: | + | 98513cca25bb: Pull complete |
- | edee0288d356: | + | Digest: sha256:0a182cb82c93939407967d6d71d6caf11dcef0e5689c6afe2d60518e3b34ab86 |
- | ea2a9399d365: | + | Status: Downloaded newer image for registry:latest |
- | ddf532273b60: | + | 272df4a849bcbc58a70d6c8e1e74751f24e485fd8ad6817427ef180b9f28b5f8 |
- | e9e91aa1843e: | + | |
- | 6144b0ffbb4c: Pull complete | + | |
- | Digest: sha256:3cac1869696e4ff3435bbc30391749ac373f7471736dbb48dfa9bfde08c4efd2 | + | |
- | Status: Downloaded newer image for registry:2.0 | + | |
- | c4c7cad999cdd77df78a21897bd11c4742a094c1c76a2134fbe4a4d2d92bff0e | + | |
</ | </ | ||
Ligne 1353: | Ligne 1318: | ||
< | < | ||
- | root@debian9:~# lynx --dump http:// | + | root@debian11:~# lynx --dump http:// |
- | {}root@debian9:~# | + | {}root@debian11:~# |
</ | </ | ||
- | <WRAP center round important> | + | <WRAP center round important |
**Important** - Notez la réponse du serveur est **{}** soit une liste JSON vide. | **Important** - Notez la réponse du serveur est **{}** soit une liste JSON vide. | ||
</ | </ | ||
Ligne 1364: | Ligne 1329: | ||
< | < | ||
- | root@debian9:~# docker tag i2tch/ | + | root@debian11:~# docker tag i2tch/ |
</ | </ | ||
- | |||
- | <WRAP center round important> | ||
- | **Important** - Notez que le tag **i2tch/ | ||
- | </ | ||
Envoyez votre image **localhost: | Envoyez votre image **localhost: | ||
< | < | ||
- | root@debian9:~# docker push localhost: | + | root@debian11:~# docker push localhost: |
- | The push refers to a repository [localhost: | + | Using default tag: latest |
- | 873a8ac77d4d: Pushed | + | The push refers to repository [localhost: |
- | b362758f4793: Pushed | + | f981bd64e799: Pushed |
- | latest: digest: sha256:30866da81d92d2a1015b869c596ddd6e188f33894c41d8effa2161e5c2862b1f | + | 74ddd0ec08fa: Pushed |
+ | latest: digest: sha256:32f7a11d8a8523bb5b4ac0986844d569ca96df4d1875e7e678a885ee3a3c61c3 | ||
</ | </ | ||
Ligne 1384: | Ligne 1346: | ||
< | < | ||
- | root@debian9:~# lynx --dump http:// | + | root@debian11:~# lynx --dump http:// |
{" | {" | ||
- | </ | ||
- | |||
- | < | ||
- | root@debian9: | ||
- | REPOSITORY | ||
- | i2tch/ | ||
- | localhost: | ||
- | registry | ||
</ | </ | ||
Ligne 1400: | Ligne 1354: | ||
Actuellement, | Actuellement, | ||
- | Connectez-vous à la VM Debian_9_1 | + | Connectez-vous à la VM **CentOS_10.0.2.45_SSH** à partir de votre VM **Debian_10.0.2.46_SSH** |
< | < | ||
- | trainee@traineeXX:~$ ssh -l trainee 10.0.2.61 | + | root@debian11:~# ssh -l trainee 10.0.2.45 |
+ | trainee@10.0.2.45' | ||
+ | Activate the web console with: systemctl enable --now cockpit.socket | ||
+ | |||
+ | Last login: Wed Nov 15 05:24:16 2023 from 10.0.2.1 | ||
+ | [trainee@centos8 ~]$ | ||
</ | </ | ||
- | En tant que root, modifiez le nom d' | + | Devenez |
< | < | ||
- | trainee@debian91:~$ su - | + | [trainee@centos8 |
- | Mot de passe : fenestros | + | Password: fenestros |
- | root@debian91:~# nmcli general hostname myregistry.i2tch.loc | + | [root@centos8 |
- | root@debian91: | + | |
- | myregistry.i2tch.loc | + | |
</ | </ | ||
- | Installez Docker | + | Modifiez le nom d' |
< | < | ||
- | root@debian91:~# apt-get update | + | [root@centos8 |
- | root@debian91: | + | [root@centos8 |
- | root@debian91: | + | myregistry.i2tch.loc |
- | root@debian91:~# add-apt-repository "deb [arch=amd64] https:// | + | |
- | root@debian91: | + | |
- | root@debian91: | + | |
</ | </ | ||
Ligne 1430: | Ligne 1384: | ||
< | < | ||
- | root@debian91:~# vi / | + | [root@centos8 |
- | root@debian91:~# cat / | + | [root@centos8 |
- | 127.0.0.1 localhost | + | 127.0.0.1 |
- | 10.0.2.60 debian9.i2tch.loc debian9 | + | ::1 |
- | 10.0.2.61 myregistry.i2tch.loc | + | 10.0.2.45 myregistry.i2tch.loc |
- | 10.0.2.62 manager.i2tch.loc manager | + | 10.0.2.46 |
- | 10.0.2.63 worker1.i2tch.loc worker1 | + | |
- | 10.0.2.64 worker2.i2tch.loc worker2 | + | |
- | + | ||
- | # The following lines are desirable for IPv6 capable hosts | + | |
- | ::1 | + | |
- | ff02::1 ip6-allnodes | + | |
- | ff02::2 ip6-allrouters | + | |
</ | </ | ||
Ligne 1448: | Ligne 1395: | ||
< | < | ||
- | root@debian91:~# cd / && | + | [root@centos8 |
- | Generating a 4096 bit RSA private key | + | |
- | ............................................................++ | + | [root@centos8 /]# vi myconfig.cnf |
- | .......................................................................................................................................++ | + | |
+ | [root@centos8 /]# cat myconfig.cnf | ||
+ | [ req ] | ||
+ | distinguished_name = dn | ||
+ | x509_extensions = extensions | ||
+ | prompt = no | ||
+ | |||
+ | [ extensions ] | ||
+ | subjectAltName = DNS: | ||
+ | |||
+ | [ dn ] | ||
+ | 0.DC = loc | ||
+ | 1.DC = i2tch | ||
+ | commonName = i2tch.loc | ||
+ | |||
+ | [root@centos8 ~]# mkdir certs && openssl req -config myconfig.cnf | ||
+ | Generating a RSA private key | ||
+ | ...............................................................................................................................................................................................++++ | ||
+ | ......++++ | ||
writing new private key to ' | writing new private key to ' | ||
----- | ----- | ||
- | You are about to be asked to enter information that will be incorporated | + | |
- | into your certificate request. | + | [root@centos8 |
- | What you are about to enter is what is called a Distinguished Name or a DN. | + | |
- | There are quite a few fields but you can leave some blank | + | |
- | For some fields there will be a default value, | + | |
- | If you enter ' | + | |
- | ----- | + | |
- | Country Name (2 letter code) [AU]:FR | + | |
- | State or Province Name (full name) [Some-State]: | + | |
- | Locality Name (eg, city) []:Toulon | + | |
- | Organization Name (eg, company) [Internet Widgits Pty Ltd]:I2TCH LTD | + | |
- | Organizational Unit Name (eg, section) []: | + | |
- | Common Name (e.g. server FQDN or YOUR name) []: | + | |
- | Email Address []: | + | |
- | root@registry:/# ls certs/ | + | |
domain.crt | domain.crt | ||
</ | </ | ||
- | Créez un conteneur en mode sécurisé avec TLS à partir | + | Déconnectez-vous |
< | < | ||
- | root@registry:/# docker run -d -p 5000:5000 --name registry -v `pwd`/ | + | [root@centos8 |
- | 943c01b67cf3f461270a55ac3d9df6622cc9d74e5f272e17153183ff29ee5932 | + | logout |
- | root@debian9:/# | + | [trainee@centos8 ~]$ exit |
- | + | logout | |
- | root@registry:/# | + | Connection to 10.0.2.45 closed. |
- | CONTAINER ID IMAGE | + | root@debian11:~# |
- | 943c01b67cf3 | + | |
</ | </ | ||
- | Envoyez une copie du fichier | + | Re-connectez-vous à la VM **CentOS8_10.0.2.45_SSH** : |
< | < | ||
- | root@debian91:~# scp / | + | root@debian11:~# ssh -l trainee 10.0.2.45 |
- | The authenticity of host '10.0.2.60 (10.0.2.60)' | + | trainee@10.0.2.45's password: trainee |
- | ECDSA key fingerprint is 79: | + | Activate the web console with: systemctl enable --now cockpit.socket |
- | Are you sure you want to continue connecting (yes/no)? yes | + | |
- | Warning: Permanently added '10.0.2.60' (ECDSA) to the list of known hosts. | + | Last login: Fri Dec 15 01:07:37 2023 from 10.0.2.46 |
- | trainee@10.0.2.60' | + | [trainee@centos8 ~]$ |
- | domain.crt | + | |
</ | </ | ||
- | ou : | + | Devenez root : |
< | < | ||
- | root@debian91:~# scp / | + | [trainee@myregistry |
- | The authenticity of host ' | + | Password: fenestros |
- | ECDSA key fingerprint is 79:00: | + | [root@myregistry ~]# |
- | Are you sure you want to continue connecting (yes/no)? yes | + | |
- | Warning: Permanently added ' | + | |
- | trainee@10.0.2.40' | + | |
- | domain.crt | + | |
</ | </ | ||
- | ===Configurer le Client=== | + | Créez un conteneur en mode sécurisé avec TLS à partir de l' |
- | Sortez | + | < |
+ | [root@myregistry ~]# docker run -d -p 5000:5000 --name registry -v / | ||
+ | Unable to find image ' | ||
+ | latest: Pulling from library/ | ||
+ | c926b61bad3b: | ||
+ | 5501dced60f8: | ||
+ | e875fe5e6b9c: | ||
+ | 21f4bf2f86f9: | ||
+ | 98513cca25bb: | ||
+ | Digest: sha256: | ||
+ | Status: Downloaded newer image for registry: | ||
+ | bf0d4fe9fcb121f9c2d9e85b8f2bb54b01397602ef0dcefdfc71327acf832fec | ||
+ | |||
+ | [root@myregistry ~]# docker ps -a | ||
+ | CONTAINER ID | ||
+ | bf0d4fe9fcb1 | ||
+ | 90267aac9800 | ||
+ | </ | ||
+ | |||
+ | Envoyez une copie du fichier **/ | ||
< | < | ||
- | trainee@traineeXX:~$ ssh -l trainee 10.0.2.60 | + | [root@myregistry ~]# scp / |
+ | The authenticity of host ' | ||
+ | ECDSA key fingerprint is SHA256: | ||
+ | Are you sure you want to continue connecting (yes/ | ||
+ | Warning: Permanently added ' | ||
+ | trainee@10.0.2.46's password: | ||
+ | domain.crt | ||
</ | </ | ||
- | Passez en tant que **root** : | + | ===Configurer le Client=== |
+ | |||
+ | Sortez de la VM **CentOS8_10.0.2.45_SSH** : | ||
< | < | ||
- | trainee@debian9:~$ su - | + | [root@myregistry ~]# exit |
- | Mot de passe : fenestros | + | logout |
- | root@debian9:~# | + | [trainee@myregistry |
+ | logout | ||
+ | Connection to 10.0.2.45 closed. | ||
+ | root@debian11:~# | ||
</ | </ | ||
Ligne 1527: | Ligne 1503: | ||
< | < | ||
- | root@debian9:~# docker | + | root@debian11:~# docker |
- | CONTAINER ID IMAGE | + | |
- | c4c7cad999cd | + | |
- | 21b0490a93dd | + | |
- | + | ||
- | root@debian9: | + | |
registry | registry | ||
- | |||
- | root@debian9: | ||
- | CONTAINER ID IMAGE | ||
- | 21b0490a93dd | ||
</ | </ | ||
Ligne 1543: | Ligne 1510: | ||
< | < | ||
- | root@debian9:~# docker rmi registry:2.0 | + | root@debian11:~# docker rmi registry:latest |
- | Untagged: registry:2.0 | + | Untagged: registry:latest |
- | Untagged: registry@sha256: | + | Untagged: registry@sha256: |
- | Deleted: sha256:3bccd459597f38e78ce95a408e506099644ca713d79157d2f3e3a7975f1c9146 | + | Deleted: sha256:909c3ff012b7f9fc4b802b73f250ad45e4ffa385299b71fdd6813f70a6711792 |
- | Deleted: sha256:e486d081a2821af119adbc458214cacf510ebb519cdf31e04ac3d4c6ac521c31 | + | Deleted: sha256:577c3b283118ca6108a6a8c8a0a00eff666dec82c482dd239dfed49f31553df6 |
- | Deleted: sha256:d206757aba612d90965729f186dfb70aa5e63b53dafd7e7b20a76005acddfe24 | + | Deleted: sha256:2ba6acf6ed95c86cfb2c830693135513bc019a0c0cf8f2c58990bc215995699f |
- | Deleted: sha256:1b953394add763fbaa50446b03d636f453fa75b2d12676ceb4b71681b4da6e7d | + | Deleted: sha256:65920463e77382a5cbe8da3e814c4449fc665487c8a9fa4ac27179e809f5ba2e |
- | Deleted: sha256:e8a2cacb793cb843e35bbf64e9c73d685d83ecc8192fbdbc098b0e5fbcced848 | + | Deleted: sha256:54501ccbeaec2665849d200fc4a61ab7254ff0f3bd31ab673879fe321fa2ad7f |
- | Deleted: sha256:19eec9bf8dcc3cb15b93cdcff717057444c540ee641cf20b7ef647d19b9d1df4 | + | Deleted: sha256:9fe9a137fd002363ac64f5af66146702432b638a83ee0c5b620c40a9e433e813 |
- | Deleted: sha256: | + | |
- | Deleted: sha256: | + | |
- | Deleted: sha256: | + | |
- | Deleted: sha256: | + | |
- | Deleted: sha256: | + | |
- | Deleted: sha256: | + | |
- | Deleted: sha256: | + | |
- | Deleted: sha256: | + | |
- | Deleted: sha256: | + | |
- | Deleted: sha256: | + | |
- | Deleted: sha256: | + | |
- | Deleted: sha256: | + | |
- | Deleted: sha256: | + | |
- | Deleted: sha256: | + | |
- | Deleted: sha256: | + | |
- | Deleted: sha256: | + | |
- | Deleted: sha256: | + | |
- | + | ||
- | root@debian9: | + | |
- | REPOSITORY | + | |
- | i2tch/ | + | |
- | localhost: | + | |
</ | </ | ||
Ligne 1579: | Ligne 1524: | ||
< | < | ||
- | root@debian9:~# docker tag i2tch/ | + | root@debian11:~# docker tag i2tch/ |
- | root@debian9:~# docker images | + | |
- | REPOSITORY | + | root@debian11:~# docker images |
- | i2tch/ | + | REPOSITORY |
- | localhost: | + | testcache |
- | myregistry: | + | < |
+ | i2tch/ | ||
+ | localhost: | ||
+ | myregistry.i2tch.loc: | ||
+ | i2tch/ | ||
+ | i2tch/ | ||
+ | ittraining/ | ||
+ | ubuntu | ||
+ | nginx latest | ||
+ | hello-world | ||
+ | centos | ||
</ | </ | ||
- | Editez le fichier **/ | + | Editez le fichier **/ |
< | < | ||
- | root@debian9:~# vi / | + | root@debian11:~# vi /etc/hosts |
- | root@debian9:~# cat / | + | |
- | 127.0.0.1 localhost | + | root@debian11:~# cat / |
- | 10.0.2.60 debian9.i2tch.loc debian9 | + | 127.0.0.1 |
- | 10.0.2.61 myregistry.i2tch.loc | + | 10.0.2.46 |
- | 10.0.2.62 manager.i2tch.loc manager | + | 10.0.2.45 myregistry.i2tch.loc |
- | 10.0.2.63 worker1.i2tch.loc worker1 | + | |
- | 10.0.2.64 worker2.i2tch.loc worker2 | + | |
# The following lines are desirable for IPv6 capable hosts | # The following lines are desirable for IPv6 capable hosts | ||
Ligne 1608: | Ligne 1561: | ||
< | < | ||
- | root@debian9:~# mkdir -p / | + | root@debian11:~# mkdir -p / |
- | root@debian9:~# mv /tmp/ca.crt / | + | |
+ | root@debian11:~# mv /tmp/ca.crt / | ||
+ | </ | ||
+ | |||
+ | Créez le fichier **/ | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
+ | |||
+ | root@debian11: | ||
+ | {" | ||
+ | </ | ||
+ | |||
+ | Re-démarrez le service docker : | ||
+ | |||
+ | < | ||
+ | root@debian11: | ||
</ | </ | ||
Ligne 1615: | Ligne 1584: | ||
< | < | ||
- | root@debian9:~# curl http:// | + | root@debian11:~# curl -k https:// |
- | + | {}root@debian11: | |
</ | </ | ||
Ligne 1622: | Ligne 1591: | ||
< | < | ||
- | root@debian9:~# docker push myregistry: | + | root@debian11:~# docker push myregistry.i2tch.loc: |
- | The push refers to a repository [myregistry: | + | Using default tag: latest |
- | 873a8ac77d4d: Pushed | + | The push refers to repository [myregistry.i2tch.loc: |
- | b362758f4793: Pushed | + | f981bd64e799: Pushed |
- | latest: digest: sha256:30866da81d92d2a1015b869c596ddd6e188f33894c41d8effa2161e5c2862b1f | + | 74ddd0ec08fa: Pushed |
+ | latest: digest: sha256:32f7a11d8a8523bb5b4ac0986844d569ca96df4d1875e7e678a885ee3a3c61c3 | ||
</ | </ | ||
----- | ----- | ||
- | < | + | |
- | <div align=" | + | Copyright © 2024 Hugh Norris. |
- | Copyright © 2021 Hugh NORRIS | + | |
- | </ | + | |
- | </ | + |