docker pull ubuntu:jammyjammy: Pulling from library/ubuntu
Digest: sha256:c7eb020043d8fc2ae0793fb35a37bff1cf33f156d4d4b12ccc7f3ef8706c38b1
Status: Image is up to date for ubuntu:jammy
docker.io/library/ubuntu:jammy
Docker & OCI
2026-01-21
À la fin de ce cours, vous saurez :
Une image suit la spécification OCI (Open Container Initiative).
[[registry/][namespace/]repository[:tag][@digest]].
repository : partie obligatoire qui identifie le dépôt (nom du répertoire).registry : hôte du registre (optionnel); si absent on entend en pratique le registre Docker Hub (docker.io).namespace : segment optionnel pour regrouper les dépôts (sur Docker Hub, l’espace library est implicite pour les images officielles).tag : référence optionnelle lisible (ex. :latest, :1.2.3); si aucun tag n’est fourni, latest est couramment utilisé comme valeur par défaut pour l’usage, mais l’absence de tag signifie que l’image peut aussi être désignée par un digest.digest : identifiant immuable optionnel (forme sha256:<hex>); lorsqu’il est présent (@digest) il prend la priorité sur le tag pour désigner de façon exacte une image. (Les parties entre crochets [] sont optionnelles selon la spécification de référence des images.)➡️ Une image n’est pas un conteneur mais le modèle de fichier utilisé pour en créer un ou plusieurs.
pull commande pour récupérer une image depuis un registry
ubuntu:jammyIMAGE CREATED CREATED BY SIZE COMMENT
c7eb020043d8 11 days ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B
<missing> 11 days ago /bin/sh -c #(nop) ADD file:b499000226bd9a7c5… 85.6MB
<missing> 11 days ago /bin/sh -c #(nop) LABEL org.opencontainers.… 0B
<missing> 11 days ago /bin/sh -c #(nop) LABEL org.opencontainers.… 0B
<missing> 11 days ago /bin/sh -c #(nop) ARG LAUNCHPAD_BUILD_ARCH 0B
<missing> 11 days ago /bin/sh -c #(nop) ARG RELEASE 0B
Avantages :
Méthode possible mais déconseillée :
docker commitLancer un conteneur Ubuntu : docker run --name my-ubuntu --interactive ubuntu:jammy bash
Installer Git en interactif : apt-get update && apt-get install -y git
Valider l’image et supprimer le conteneur intermédiaire.
sha256:b3f8080bcc2739a7f5fab6923da1e9453c3aa5e44302b9da57fd273416b1dd62
my-ubuntu
mygit:latest est créée.mygit.IMAGE CREATED CREATED BY SIZE COMMENT
b3f8080bcc27 3 seconds ago bash - 155MB
c7eb020043d8 11 days ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B
<missing> 11 days ago /bin/sh -c #(nop) ADD file:b499000226bd9a7c5… 85.6MB
<missing> 11 days ago /bin/sh -c #(nop) LABEL org.opencontainers.… 0B
<missing> 11 days ago /bin/sh -c #(nop) LABEL org.opencontainers.… 0B
<missing> 11 days ago /bin/sh -c #(nop) ARG LAUNCHPAD_BUILD_ARCH 0B
<missing> 11 days ago /bin/sh -c #(nop) ARG RELEASE 0B
➡️ Une seule couche opaque ajoutée
Avantages :
Les exemples suivants sont accessibles dans le dépôt :
✅ Updated existing repository: ebpro/notebook-containers-intro-sample-python-helloworld
Date: 2026-01-20T20:19:15Z – Commit: 0584a56 fixes workdir – Branche: develop
Repository: https://github.com/ebpro/notebook-containers-intro-sample-python-helloworld
Local path: /home/jovyan/work/examples/github/ebpro/notebook-containers-intro-sample-python-helloworld
Status: 0
Command: git clone https://github.com/ebpro/notebook-containers-intro-sample-python-helloworld --branch develop# syntax=docker/dockerfile:1
# Choose the parent image
FROM python:3.12-slim
# An argument sets at build command with --build-arg
# It as a default value
ARG BUILD_DATE=1970-01-01T00:00:00Z
# key-value pair as image metadata
LABEL maintainer="emmanuel.bruno@univ-tln.fr"
# See http://label-schema.org/rc1/ for a list of usefull labels
LABEL org.label-schema.build-date=$BUILD_DATE
# An environment variable
ENV NAME="John Doe"
# Creates and moves to a directory
WORKDIR /app
# Copy the requirements them in the new image.
# Done before the copy of the src to limit cache invalidations
# when only source code changes.
COPY requirements.txt ./
# Installation of the dependencies
RUN pip install --requirement requirements.txt
# Copy the sources
COPY hello.py ./
# Set the default command for the image
CMD python /app/hello.pydocker image buildsha256:5f0f2e3c7ef546823c7e8ab6b88a0b1e6879b82d5e5060a54d09a149d2ead235
ℹ️ Le . est le contexte de build
Bonnes pratiques :
--tag / -t pour nommer l’image1.2.31, 1.2latest[registry/][namespace/]repository:tag
Tag à la construction (--tag / -t) :
docker run-e / --env pour variables d’environnement dans le conteneurÉtapes :
L’instruction HEALTHCHECK permet de définir une commande pour vérifier la santé d’un conteneur en cours d’exécution. Docker exécute périodiquement cette commande et utilise son code de retour pour déterminer l’état du conteneur : 0 (sain), 1 (non sain) ou 2 (réservé).
Exemple :
Options principales :
--interval: fréquence de vérification (ex. 30s).--timeout: délai maximum d’exécution de la commande (ex. 3s).--start-period: délai initial avant la première vérification (ex. 5s).--retries: nombre d’échecs consécutifs avant de considérer le conteneur comme non sain.Les HEALTHCHECK sont utiles pour l’orchestration (restart policies, load balancers) et pour détecter des services défaillants.
Principes essentiels pour réduire la surface d’attaque et rendre les images sûres :
--mount=type=secret) ou des volumes/variables d’environnement au runtime.@sha256:...) ou pinner les versions de paquets pour éviter des mises à jour non contrôlées.apt-get clean && rm -rf /var/lib/apt/lists/*).docker scan, trivy) et générer un SBOM. Ex : trivy image --severity HIGH,CRITICAL myimage:latest.--cap-drop), monter le FS en lecture seule quand possible (--read-only).ENTRYPOINT + CMD = commande complèteCMD absent, arguments passés à docker run sont ajoutés à ENTRYPOINTENTRYPOINT absent, docker run utilise CMD ou les arguments passés| Directive | Rôle |
|---|---|
| ENTRYPOINT | Comportement principal |
| CMD | Paramètres remplaçables |
➡️ Image utilisable comme un programme
Objectifs :
Fonctionnement :
FROM dans un DockerfileCOPY --from=...)Les exemples suivants sont accessibles dans le dépôt :
✅ Updated existing repository: ebpro/notebook-containers-intro-sample-c
Date: 2026-01-20T20:19:25Z – Commit: b9f1ed3 improve comments – Branche: develop
# Build stage
FROM gcc:14-bookworm AS builder
# An argument sets at build command with --build-arg
# It as a default value
ARG BUILD_DATE=1970-01-01T00:00:00Z
# key-value pair as image metadata
LABEL maintainer="emmanuel.bruno@univ-tln.fr"
# See http://label-schema.org/rc1/ for a list of usefull labels
LABEL org.label-schema.build-date=$BUILD_DATE
WORKDIR /src/app
COPY helloworld.c .
RUN gcc -Wall -Wextra -Werror -O2 -fPIE -pie -D_FORTIFY_SOURCE=2 -static-libgcc helloworld.c -o helloworld
# Runtime stage
FROM debian:bookworm-slim
# Create non-root user
RUN groupadd -r appuser && useradd -r -g appuser appuser
WORKDIR /app
# Copy only the compiled binary
COPY --from=builder --chown=appuser:appuser /src/app/helloworld /app/helloworld
# Switch to non-root user
USER appuser
# Set executable permissions
RUN chmod 550 /app/helloworld
ENTRYPOINT ["/app/helloworld"]EXPOSE dans le Dockerfile pour documenter les ports utilisés-p / --publish dans docker run pour mapper les portsDans le Dockerfile :
ℹ️ EXPOSE est informatif
docker buildx ou docker build --platformdocker buildx build --push.Dockerfile pour créer des imagesENTRYPOINT définit le comportementCMD fournit des arguments par défautpush Publier sur un registry