Containers

Containers Notebook Demo

Université de Toulon

LIS UMR CNRS 7020

2026-10-14

Introduction

  • Objectif: Introduction pratique aux containers Docker
  • Contenu: concepts clés + commandes essentielles
  • Environnement: devcontainer avec clients docker et podman

Préparation de l’environnement

Configuration

  • Docker-in-Docker: isolation complète
    • Service Docker séparé, connexion via TCP (port 2375)
  • Engine de l’hôte (dooD): performances optimales
    • Socket Unix (/var/run/docker.sock)
    • Isolation moindre → nettoyage ciblé par label (--label ebpro-render=true)
    • C’est le mode utilisé ici

Premier container

Hello World

docker run --label ebpro-render=true hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Étapes :

  1. 🔍 Recherche locale de l’image
  2. 📥 Téléchargement depuis Docker Hub (si absente)
  3. 🏗️ Création du container
  4. ▶️ Exécution + message de bienvenue
  5. ⏹️ Arrêt automatique

💡 Image ultra-légère (~1.84 kB) pour tester l’installation

Images Docker

Lister les images

docker images
                                                            i Info →   U  In Use

IMAGE                           ID             DISK USAGE   CONTENT SIZE   EXTRA

ghcr.io/ebpro/solen:quarto-full-build-20261010T172146Z

                                b4ed11d0542c       6.88GB             0B    U   

hello-world:latest              e2ac70e7319a       10.1kB             0B    U   

Colonnes :

  • REPOSITORY : nom de l’image
  • TAG : version/variante
  • IMAGE ID : identifiant unique
  • CREATED : date de création
  • SIZE : taille disque

💡 Architecture en couches → réutilisation + optimisation

Containers actifs

Lister les containers

docker ps       # containers actifs
docker ps -a    # tous les containers
CONTAINER ID   IMAGE                                                    COMMAND                  CREATED          STATUS          PORTS     NAMES
415b7921a604   ghcr.io/ebpro/solen:quarto-full-build-20261010T172146Z   "bash -lc 'source /h…"   23 seconds ago   Up 22 seconds             quarto-render-38598955399
CONTAINER ID   IMAGE                                                    COMMAND                  CREATED          STATUS                     PORTS     NAMES
288e0bb3fb8e   hello-world                                              "/hello"                 2 seconds ago    Exited (0) 1 second ago              frosty_goldstine
9e46a5e3b4d5   hello-world                                              "/hello"                 4 seconds ago    Exited (0) 2 seconds ago             pedantic_meninsky
415b7921a604   ghcr.io/ebpro/solen:quarto-full-build-20261010T172146Z   "bash -lc 'source /h…"   23 seconds ago   Up 22 seconds                        quarto-render-38598955399

Informations :

  • CONTAINER ID : identifiant court
  • IMAGE : image source
  • STATUS : Up (actif) / Exited (arrêté)
  • PORTS : mappages réseau
  • NAMES : nom du container

Container interactif

Shell interactif

Pour un shell interactif (non compatible avec l’exécution notebook) :

docker run -it --label ebpro-render=true ubuntu bash

Commande non-bloquante équivalente :

docker run --label ebpro-render=true ubuntu echo "Hello from Ubuntu container"
Hello from Ubuntu container

Options :

  • -i : garde STDIN ouvert
  • -t : alloue un pseudo-terminal
  • Résultat : shell interactif dans le container

💡 Container actif tant que le shell est ouvert

Nettoyage

Nettoyage

Commandes de nettoyage (exemples à adapter avec IDs réels) :

docker rm <container_id>       # supprimer un container
docker ps -aq --filter label=ebpro-render=true | xargs -r docker rm -f   # containers de la leçon
docker rmi <image_id>          # supprimer une image

⚠️ Contrainte : une image ne peut être supprimée si des containers l’utilisent

⚠️ Démon partagé : éviter docker container prune (supprime tout), préférer le nettoyage par label

💡 Bonnes pratiques : nettoyer régulièrement

Conclusion

Récapitulatif

✅ Concepts clés

  • Images vs Containers
  • Exécution simple et interactive
  • Surveillance et gestion
  • Nettoyage

📚 Pour aller plus loin

  • Dockerfiles (images personnalisées)
  • Docker Compose (orchestration)
  • Réseaux Docker (communication)