« Docker Images » : différence entre les versions

Page créée avec « == Copie locale == Conserver une copie locale de l’image <code>debian:latest</code> et Construire une image Docker à partir de cette copie locale, sans la re-télécharger depuis Docker Hub à chaque fois. ----- <span id="étapes-à-suivre"></span> === ✅ '''Étapes à suivre''' === <span id="télécharger-et-taguer-localement-limage-debianlatest"></span> ==== 1. '''Télécharger et taguer localement l’image <code>debian:latest</code>''' ==== Avant de... »
 
Aucun résumé des modifications
Ligne 48 : Ligne 48 :


<syntaxhighlight lang="dockerfile">FROM local/debian:2025-06 AS tools</syntaxhighlight>
<syntaxhighlight lang="dockerfile">FROM local/debian:2025-06 AS tools</syntaxhighlight>
-----
-----
<span id="étapes-pour-mettre-à-jour-limage-debianlatest-depuis-docker-hub"></span>
=== ✅ Étapes pour mettre à jour l’image <code>debian:latest</code> depuis Docker Hub ===
<span id="supprimer-ou-retaguer-limage-locale"></span>
==== 1. '''Supprimer ou retaguer l’image locale''' ====
Si tu avais tagué une image locale comme ceci :
<syntaxhighlight lang="bash">docker tag debian:latest local/debian:latest</syntaxhighlight>
Tu peux soit : - Supprimer ce tag local : <code>bash  docker rmi local/debian:latest</code> - Ou le renommer pour le conserver : <code>bash  docker tag local/debian:latest local/debian:backup</code>
<span id="tirer-la-dernière-version-depuis-docker-hub"></span>
==== 2. '''Tirer la dernière version depuis Docker Hub''' ====
<syntaxhighlight lang="bash">docker pull debian:latest</syntaxhighlight>
Cela télécharge la version la plus récente de l’image officielle.
<span id="optionnel-re-tagger-pour-ton-usage-local"></span>
==== 3. '''(Optionnel) Re-tagger pour ton usage local''' ====
Si tu veux continuer à utiliser un tag local dans ton <code>Dockerfile</code> :
<syntaxhighlight lang="bash">docker tag debian:latest local/debian:latest</syntaxhighlight>
<span id="rebuilder-ton-image"></span>
==== 4. '''Rebuilder ton image''' ====
Ensuite, tu peux reconstruire ton image avec Docker ou Docker Compose :
<syntaxhighlight lang="bash">docker compose build --no-cache</syntaxhighlight>
L’option <code>--no-cache</code> garantit que tout est reconstruit à partir de la nouvelle image de base.
-----
<span id="astuce-bonus-automatiser-la-mise-à-jour"></span>
=== 🧠 Astuce bonus : Automatiser la mise à jour ===
Tu peux créer un petit script <code>update-base.sh</code> :
<syntaxhighlight lang="bash">#!/bin/bash
docker pull debian:latest
docker tag debian:latest local/debian:latest
docker compose build --no-cache</syntaxhighlight>


[[Catégorie:Docker]]
[[Catégorie:Docker]]