docker --versionDocker version 29.9.2, build a82e528
Découvrir les conteneurs avec Docker
Donner le goût des conteneurs en pratiquant :
run, ps, stop, rmCe TP n’est pas un TP de production. Il vise à construire une intuition correcte des conteneurs.
docker --versionDocker version 29.9.2, build a82e528
Si l’installation de Docker localement est difficile, vous pouvez utiliser un environnement en ligne tel que Play with Docker ou Katacoda.
Les commandes présentées dans ce TP utilisent les formes longues des options pour plus de clarté. Formes longues ↔︎ courtes
-d-p-v-i-t-eCréer un dossier de travail et s’y positionner ($TP_DIR="~/tp0-containers-101") :
Nettoyage optionnel des restes d’exécutions précédentes :
docker rm --force tp0-nginx tp0-app 2>/dev/null || true
docker network rm tp0-net 2>/dev/null || true
docker image rm tp0-app:0.1 2>/dev/null || trueVoir un conteneur en cours d’exécution.
La commande suivante lance un conteneur nginx (serveur web) en arrière-plan, nommé tp0-nginx, exposant le port 80 du conteneur sur le port 8080 de l’hôte :
docker rm -f tp0-nginx >/dev/null 2>&1 || true
docker run --label teaching-demo=true --detach \
--name tp0-nginx \
--publish :80 \
nginx:stableUnable to find image 'nginx:stable' locally
stable: Pulling from library/nginx
37fb86c2a767: Pulling fs layer
8aac28a8701c: Pulling fs layer
d573f8ac02d6: Pulling fs layer
77dc24f83d75: Pulling fs layer
3a0b39cdd8e2: Pulling fs layer
59f811ed280c: Pulling fs layer
aa560e7d269a: Pulling fs layer
77dc24f83d75: Waiting
3a0b39cdd8e2: Waiting
aa560e7d269a: Waiting
59f811ed280c: Waiting
d573f8ac02d6: Downloading 627B/627B
d573f8ac02d6: Download complete
8aac28a8701c: Downloading 339.6kB/33.76MB
37fb86c2a767: Downloading 310.7kB/29.86MB
8aac28a8701c: Downloading 4.134MB/33.76MB
37fb86c2a767: Downloading 5.914MB/29.86MB
8aac28a8701c: Downloading 8.937MB/33.76MB
37fb86c2a767: Downloading 13.07MB/29.86MB
37fb86c2a767: Downloading 20.86MB/29.86MB
8aac28a8701c: Downloading 13.74MB/33.76MB
37fb86c2a767: Downloading 28.02MB/29.86MB
8aac28a8701c: Downloading 18.55MB/33.76MB
37fb86c2a767: Verifying Checksum
37fb86c2a767: Download complete
37fb86c2a767: Extracting 327.7kB/29.86MB
8aac28a8701c: Downloading 23.39MB/33.76MB
77dc24f83d75: Downloading 965B/965B
77dc24f83d75: Verifying Checksum
77dc24f83d75: Download complete
37fb86c2a767: Extracting 3.932MB/29.86MB
8aac28a8701c: Downloading 31.31MB/33.76MB
8aac28a8701c: Verifying Checksum
8aac28a8701c: Download complete
37fb86c2a767: Extracting 7.864MB/29.86MB
3a0b39cdd8e2: Downloading 405B/405B
3a0b39cdd8e2: Verifying Checksum
3a0b39cdd8e2: Download complete
37fb86c2a767: Extracting 10.16MB/29.86MB
59f811ed280c: Downloading 1.21kB/1.21kB
59f811ed280c: Verifying Checksum
59f811ed280c: Download complete
37fb86c2a767: Extracting 12.12MB/29.86MB
aa560e7d269a: Downloading 1.398kB/1.398kB
aa560e7d269a: Verifying Checksum
aa560e7d269a: Download complete
37fb86c2a767: Extracting 16.06MB/29.86MB
37fb86c2a767: Extracting 19.66MB/29.86MB
37fb86c2a767: Extracting 23.92MB/29.86MB
37fb86c2a767: Extracting 26.21MB/29.86MB
37fb86c2a767: Extracting 28.51MB/29.86MB
37fb86c2a767: Extracting 29.16MB/29.86MB
37fb86c2a767: Extracting 29.82MB/29.86MB
37fb86c2a767: Extracting 29.86MB/29.86MB
37fb86c2a767: Pull complete
8aac28a8701c: Extracting 360.4kB/33.76MB
8aac28a8701c: Extracting 2.884MB/33.76MB
8aac28a8701c: Extracting 6.128MB/33.76MB
8aac28a8701c: Extracting 9.372MB/33.76MB
8aac28a8701c: Extracting 12.62MB/33.76MB
8aac28a8701c: Extracting 14.78MB/33.76MB
8aac28a8701c: Extracting 18.74MB/33.76MB
8aac28a8701c: Extracting 22.35MB/33.76MB
8aac28a8701c: Extracting 25.23MB/33.76MB
8aac28a8701c: Extracting 28.48MB/33.76MB
8aac28a8701c: Extracting 31MB/33.76MB
8aac28a8701c: Extracting 31.36MB/33.76MB
8aac28a8701c: Extracting 33.76MB/33.76MB
8aac28a8701c: Pull complete
d573f8ac02d6: Extracting 627B/627B
d573f8ac02d6: Extracting 627B/627B
d573f8ac02d6: Pull complete
77dc24f83d75: Extracting 965B/965B
77dc24f83d75: Extracting 965B/965B
77dc24f83d75: Pull complete
3a0b39cdd8e2: Extracting 405B/405B
3a0b39cdd8e2: Extracting 405B/405B
3a0b39cdd8e2: Pull complete
59f811ed280c: Extracting 1.21kB/1.21kB
59f811ed280c: Extracting 1.21kB/1.21kB
59f811ed280c: Pull complete
aa560e7d269a: Extracting 1.398kB/1.398kB
aa560e7d269a: Extracting 1.398kB/1.398kB
aa560e7d269a: Pull complete
Digest: sha256:d2320e162dd44040e1779dce7d728e228592699bc1ab4588d6dc52cfd47859ad
Status: Downloaded newer image for nginx:stable
7647ebfb4c763491feaa1a68db99a5163b4ed744358cc48f8aaac0c09b07022c
Vérifier qu’il est bien lancé :
docker container lsCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7647ebfb4c76 nginx:stable "/docker-entrypoint.…" 3 seconds ago Up Less than a second 0.0.0.0:32768->80/tcp, [::]:32768->80/tcp tp0-nginx
b18f5295f71f ghcr.io/ebpro/solen:quarto-full-v1.3.42 "bash -lc 'source /h…" 59 seconds ago Up 57 seconds quarto-render-44367462608
Il est accessible via le port 8080 de l’hôte avec un navigateur web ou curl :
Tester :
curl --max-time 30 --include http://localhost:8080curl: (7) Failed to connect to dind port 8080 after 0 ms: Couldn’t connect to server (skipped: no DIND host in CI)
Les 10 derniers logs du conteneur peuvent être consultés avec :
docker logs tp0-nginx --tail 102026/11/18 19:31:06 [notice] 1#1: start worker process 51
2026/11/18 19:31:06 [notice] 1#1: start worker process 52
2026/11/18 19:31:06 [notice] 1#1: start worker process 53
2026/11/18 19:31:06 [notice] 1#1: start worker process 54
2026/11/18 19:31:06 [notice] 1#1: start worker process 55
2026/11/18 19:31:06 [notice] 1#1: start worker process 56
2026/11/18 19:31:06 [notice] 1#1: start worker process 57
2026/11/18 19:31:06 [notice] 1#1: start worker process 58
2026/11/18 19:31:06 [notice] 1#1: start worker process 59
2026/11/18 19:31:06 [notice] 1#1: start worker process 60
Le conteneur peut être arrêté avec :
docker stop tp0-nginxtp0-nginx
Les conteneurs y compris arrêtés peuvent être listés avec :
docker container ls --allCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7647ebfb4c76 nginx:stable "/docker-entrypoint.…" 5 seconds ago Exited (0) Less than a second ago tp0-nginx
b18f5295f71f ghcr.io/ebpro/solen:quarto-full-v1.3.42 "bash -lc 'source /h…" About a minute ago Up 59 seconds quarto-render-44367462608
et supprimé avec :
docker rm --force tp0-nginxtp0-nginx
Un conteneur = un service/processus isolé
Pour relier le système de fichier de l’hôte et celui du conteneur, on utilise des volumes.
Créer un dossier www/ sur l’hôte avec une page HTML simple :
mkdir -p www
echo "<h1>Hello from host</h1>" > www/index.htmlLancer un serveur web nginx en montant le dossier www/ de l’hôte dans le dossier /usr/share/nginx/html du conteneur (en lecture seule avec :ro) :
docker rm -f tp0-nginx >/dev/null 2>&1 || true
docker run --label teaching-demo=true --detach \
--name tp0-nginx \
--publish :80 \
--volume "$PWD/www":/usr/share/nginx/html:ro \
nginx:stableIl est accessible via le port 8080 de l’hôte avec un navigateur web ou curl :
curl est utilisé ici pour afficher les headers HTTP et le contenu de la page.
curl --max-time 30 --include http://localhost:8080curl: (7) Failed to connect to dind port 8080 after 0 ms: Couldn't connect to server
curl failed or timed out
Modifier www/index.html sur l’hôte et rafraîchir la page ou relancer curl.
echo "<h1>Hello from host - updated</h1>" > www/index.html
curl --max-time 30 --include http://localhost:8080Nettoyage :
Les données ne vivent pas dans le conteneur, il doit être éphémère
Il est important de comprendre la différence entre un conteneur et une image. Il est possible d’executer des conteneurs en mode interactif pour explorer leur contenu et interagir avec eux.
Il est déconseillé d’installer des logiciels directement dans un conteneur en production.
docker run --label teaching-demo=true --rm ubuntu:22.04 </dev/nullDans le conteneur, exécuter les commandes suivantes pour explorer le système, créer un fichier et installer curl.
cat /etc/os-release
uname -a
echo "Hello from inside the container" > /tmp/hello.txt
apt update && apt install -y curl
curl --max-time 30 --include https://example.comquitter le conteneur avec la commande exit (ou Ctrl+D).
Unable to find image 'ubuntu:22.04' locally
22.04: Pulling from library/ubuntu
02163de04dd1: Pulling fs layer
02163de04dd1: Downloading 310.7kB/30.07MB
02163de04dd1: Downloading 8.093MB/30.07MB
02163de04dd1: Downloading 15.88MB/30.07MB
02163de04dd1: Downloading 23.66MB/30.07MB
02163de04dd1: Verifying Checksum
02163de04dd1: Download complete
02163de04dd1: Extracting 327.7kB/30.07MB
02163de04dd1: Extracting 2.949MB/30.07MB
02163de04dd1: Extracting 5.243MB/30.07MB
02163de04dd1: Extracting 7.209MB/30.07MB
02163de04dd1: Extracting 8.52MB/30.07MB
02163de04dd1: Extracting 10.16MB/30.07MB
02163de04dd1: Extracting 13.43MB/30.07MB
02163de04dd1: Extracting 17.04MB/30.07MB
02163de04dd1: Extracting 20.64MB/30.07MB
02163de04dd1: Extracting 23.59MB/30.07MB
02163de04dd1: Extracting 25.56MB/30.07MB
02163de04dd1: Extracting 25.89MB/30.07MB
02163de04dd1: Extracting 27.85MB/30.07MB
02163de04dd1: Extracting 28.84MB/30.07MB
02163de04dd1: Extracting 29.82MB/30.07MB
02163de04dd1: Extracting 30.07MB/30.07MB
02163de04dd1: Pull complete
Digest: sha256:9abcaffc92a5279fff3a6a41635c0800ea33e528425fb389658806476e7defde
Status: Downloaded newer image for ubuntu:22.04
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package openssl.
(Reading database ... 4393 files and directories currently installed.)
Preparing to unpack .../00-openssl_3.0.2-0ubuntu1.30_amd64.deb ...
Unpacking openssl (3.0.2-0ubuntu1.30) ...
Selecting previously unselected package ca-certificates.
Preparing to unpack .../01-ca-certificates_20260816ubuntu0.22.04.2_all.deb ...
Unpacking ca-certificates (20260816ubuntu0.22.04.2) ...
Selecting previously unselected package libnghttp2-14:amd64.
Preparing to unpack .../02-libnghttp2-14_1.43.0-1ubuntu0.4_amd64.deb ...
Unpacking libnghttp2-14:amd64 (1.43.0-1ubuntu0.4) ...
Selecting previously unselected package libpsl5:amd64.
Preparing to unpack .../03-libpsl5_0.21.0-1.2build2_amd64.deb ...
Unpacking libpsl5:amd64 (0.21.0-1.2build2) ...
Selecting previously unselected package publicsuffix.
Preparing to unpack .../04-publicsuffix_20211207.1025-1_all.deb ...
Unpacking publicsuffix (20211207.1025-1) ...
Selecting previously unselected package libbrotli1:amd64.
Preparing to unpack .../05-libbrotli1_1.0.9-2ubuntu0.1_amd64.deb ...
Unpacking libbrotli1:amd64 (1.0.9-2ubuntu0.1) ...
Selecting previously unselected package libsasl2-modules-db:amd64.
Preparing to unpack .../06-libsasl2-modules-db_2.1.27+dfsg2-3ubuntu1.2_amd64.deb ...
Unpacking libsasl2-modules-db:amd64 (2.1.27+dfsg2-3ubuntu1.2) ...
Selecting previously unselected package libsasl2-2:amd64.
Preparing to unpack .../07-libsasl2-2_2.1.27+dfsg2-3ubuntu1.2_amd64.deb ...
Unpacking libsasl2-2:amd64 (2.1.27+dfsg2-3ubuntu1.2) ...
Selecting previously unselected package libldap-2.5-0:amd64.
Preparing to unpack .../08-libldap-2.5-0_2.5.20+dfsg-0ubuntu0.22.04.1_amd64.deb ...
Unpacking libldap-2.5-0:amd64 (2.5.20+dfsg-0ubuntu0.22.04.1) ...
Selecting previously unselected package librtmp1:amd64.
Preparing to unpack .../09-librtmp1_2.4+20151223.gitfa8646d.1-2build4_amd64.deb ...
Unpacking librtmp1:amd64 (2.4+20151223.gitfa8646d.1-2build4) ...
Selecting previously unselected package libssh-4:amd64.
Preparing to unpack .../10-libssh-4_0.9.6-2ubuntu0.22.04.8_amd64.deb ...
Unpacking libssh-4:amd64 (0.9.6-2ubuntu0.22.04.8) ...
Selecting previously unselected package libcurl4:amd64.
Preparing to unpack .../11-libcurl4_7.81.0-1ubuntu1.30_amd64.deb ...
Unpacking libcurl4:amd64 (7.81.0-1ubuntu1.30) ...
Selecting previously unselected package curl.
Preparing to unpack .../12-curl_7.81.0-1ubuntu1.30_amd64.deb ...
Unpacking curl (7.81.0-1ubuntu1.30) ...
Selecting previously unselected package libldap-common.
Preparing to unpack .../13-libldap-common_2.5.20+dfsg-0ubuntu0.22.04.1_all.deb ...
Unpacking libldap-common (2.5.20+dfsg-0ubuntu0.22.04.1) ...
Selecting previously unselected package libsasl2-modules:amd64.
Preparing to unpack .../14-libsasl2-modules_2.1.27+dfsg2-3ubuntu1.2_amd64.deb ...
Unpacking libsasl2-modules:amd64 (2.1.27+dfsg2-3ubuntu1.2) ...
Setting up libpsl5:amd64 (0.21.0-1.2build2) ...
Setting up libbrotli1:amd64 (1.0.9-2ubuntu0.1) ...
Setting up libsasl2-modules:amd64 (2.1.27+dfsg2-3ubuntu1.2) ...
Setting up libnghttp2-14:amd64 (1.43.0-1ubuntu0.4) ...
Setting up libldap-common (2.5.20+dfsg-0ubuntu0.22.04.1) ...
Setting up libsasl2-modules-db:amd64 (2.1.27+dfsg2-3ubuntu1.2) ...
Setting up librtmp1:amd64 (2.4+20151223.gitfa8646d.1-2build4) ...
Setting up libsasl2-2:amd64 (2.1.27+dfsg2-3ubuntu1.2) ...
Setting up libssh-4:amd64 (0.9.6-2ubuntu0.22.04.8) ...
Setting up openssl (3.0.2-0ubuntu1.30) ...
Setting up publicsuffix (20211207.1025-1) ...
Setting up libldap-2.5-0:amd64 (2.5.20+dfsg-0ubuntu0.22.04.1) ...
Setting up ca-certificates (20260816ubuntu0.22.04.2) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.34.0 /usr/local/share/perl/5.34.0 /usr/lib/x86_64-linux-gnu/perl5/5.34 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.34 /usr/share/perl/5.34 /usr/local/lib/site_perl) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Clearing symlinks in /etc/ssl/certs...
done.
Updating certificates in /etc/ssl/certs...
120 added, 0 removed; done.
Setting up libcurl4:amd64 (7.81.0-1ubuntu1.30) ...
Setting up curl (7.81.0-1ubuntu1.30) ...
Processing triggers for libc-bin (2.35-0ubuntu3.15) ...
Processing triggers for ca-certificates (20260816ubuntu0.22.04.2) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
Linux 3582eae322da 6.8.0-149-generic #149-Ubuntu SMP PREEMPT_DYNAMIC Fri Oct 23 13:21:10 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:03 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:03 --:--:-- 0
100 577 0 577 0 0 166 0 --:--:-- 0:00:03 --:--:-- 166
HTTP/2 200
date: Wed, 18 Nov 2026 19:31:42 GMT
content-type: text/html; charset=utf-8
server: cloudflare
last-modified: Wed, 18 Nov 2026 10:54:07 GMT
allow: GET, HEAD
accept-ranges: bytes
age: 11
cf-cache-status: HIT
cf-ray: a5c9659f28b93c86-CDG
alt-svc: h3=":443"; ma=86400
<!doctype html><html lang=en><head><meta charset=utf-8><link rel=icon href=data:,><meta name=viewport content="width=device-width,initial-scale=1"><title>Example Domain</title><style>html{color-scheme:light dark;background:light-dark(#eee,#222)}body{font:16px/1.6 system-ui,sans-serif;max-width:26em;margin:auto;padding:25vh 2em 2em;text-align:center}</style></head><body><p>This domain is for use in documentation examples without needing permission. This is not a service; avoid relying on it for testing and monitoring purposes.</p><script src=/s.js></script></body></html>
Relancer :
docker run --label teaching-demo=true --rm ubuntu:22.04 bash </dev/null
cat /tmp/hello.txt # ❌ disparu
curl --max-time 30 --include https://example.com # ❌ curl non installéCe qui n’est pas dans une image est perdu
Pour rendre l’installation reproductible et persistante, il faut créer une image. L’approche standard est d’écrire un fichier Dockerfile décrivant l’image.
Créer un Dockerfile qui installe curl (RUN) dans une image basée sur ubuntu:22.04 (FROM) et qui lance bash par défaut (CMD).
Construire l’image Docker à partir d’un Dockerfile dans le dossier courant (.) avec le tag tp0-ubuntu-curl :
docker build --tag tp0-ubuntu-curl .Tester en mode interactif en exécutant la commande curl --max-time 30 --include https://example.com dans le conteneur :
docker run --label teaching-demo=true --rm tp0-ubuntu-curl </dev/nullla commande peut aussi être passée en paramètre du docker run :
docker run --label teaching-demo=true --rm tp0-ubuntu-curl \
curl --max-time 30 --include https://example.com % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:03 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:03 --:--:-- 0
100 577 0 577 0 0 162 0 --:--:-- 0:00:03 --:--:-- 162
HTTP/2 200
date: Wed, 18 Nov 2026 19:32:08 GMT
content-type: text/html; charset=utf-8
server: cloudflare
last-modified: Wed, 18 Nov 2026 10:54:07 GMT
allow: GET, HEAD
accept-ranges: bytes
age: 3
cf-cache-status: HIT
cf-ray: a5c96641dbb611ff-CDG
alt-svc: h3=":443"; ma=86400
<!doctype html><html lang=en><head><meta charset=utf-8><link rel=icon href=data:,><meta name=viewport content="width=device-width,initial-scale=1"><title>Example Domain</title><style>html{color-scheme:light dark;background:light-dark(#eee,#222)}body{font:16px/1.6 system-ui,sans-serif;max-width:26em;margin:auto;padding:25vh 2em 2em;text-align:center}</style></head><body><p>This domain is for use in documentation examples without needing permission. This is not a service; avoid relying on it for testing and monitoring purposes.</p><script src=/s.js></script></body></html>
En suivant la même approche, il est possible de créer une image contenant une application Python simple.
Créer une structure de dossiers app/ avec une application serveur Web minimale en Python :
app
├── Dockerfile
└── app.py
1 directory, 2 files
L’application Python
app/app.py
Un fichier Dockerfile qui construit l’image de l’application Python en utilisant l’image officielle python:3.11-slim comme base, en copiant le fichier app.py dans le conteneur et en définissant la commande par défaut pour exécuter l’application.
Construire l’image Docker depuis le dossier app/ avec le tag tp0-app:0.0.1 :
docker build --tag tp0-app:0.0.1 .Exécuter le conteneur en mappant le port 5000 du conteneur (sur lequel l’application écoute) sur le port 5000 de l’hôte :
docker rm -f tp0-app >/dev/null 2>&1 || true
docker run --label teaching-demo=true --detach \
--name tp0-app \
--publish :5000 \
tp0-app:0.0.1dc0253db0a47187081c493227905e2eb2abfd237397c3fd175858e2371fad796
Tester l’application avec curl depuis l’hôte :
curl --max-time 30 --include http://localhost:5000curl: (7) Failed to connect to dind port 5000 after 0 ms: Couldn't connect to server
(skipped: no DIND host in CI)
Nettoyer le conteneur (arrêt et suppression) :
docker stop tp0-app
docker rm tp0-apptp0-app
tp0-app
Il est possible de faire fonctionner plusieurs conteneurs ensemble via un réseau Docker. Dans cet exercice, nous allons créer un réseau Docker et y connecter le conteneur de l’application Python et et autre conteneur curl pour tester l’application.
Créer un réseau (virtuel) Docker nommé tp0-net :
docker network create tp0-netaa5db0aa467ed06e83c4ada67cc49a622d6c3bc620403266e18e028cfe58dae9
Lancer le conteneur de l’application Python dans ce réseau :
docker rm -f tp0-app >/dev/null 2>&1 || true
docker run --label teaching-demo=true --detach \
--name tp0-app \
--network tp0-net \
tp0-app:0.0.1c64629babf269c3431c4dcd3ce199f7e359c191afb1de2038455ac9fa8163738
Tester l’application avec un conteneur curl connecté au même réseau Docker, en utilisant le nom du conteneur tp0-app comme hostname pour le service :
#| echo: true
#| output: asis
docker run --label teaching-demo=true --rm \
--network tp0-net \
curlimages/curl --max-time 30 --include http://tp0-app:5000Nettoyage :
Les conteneurs communiquent via des réseaux virtuels et des noms DNS internes
Les conteneurs permettent de déployer des applications complexes de manière reproductible et en isolant les différentes parties.