tech:docker_image_build
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 | ||
| tech:docker_image_build [2026/03/28 22:32] – Jean-Baptiste | tech:docker_image_build [2026/06/07 19:12] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | < | ||
| + | {{tag> | ||
| + | # Docker image build | ||
| + | |||
| + | Voir : | ||
| + | * [[https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * [[docker_install_dokuwiki|Exemple de Dockerfile pour Dokuwiki]] | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | Ansible : | ||
| + | * https:// | ||
| + | |||
| + | |||
| + | Outils / Méthode / Container Image Builders : | ||
| + | * Docker / Dockerfile | ||
| + | * Buildah | ||
| + | * * Buildpacks / pack https:// | ||
| + | * openshift-imagebuilder | ||
| + | * [[https:// | ||
| + | * Kaniko https:// | ||
| + | * S2I | ||
| + | * CNB | ||
| + | * Paketo | ||
| + | * umoci | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ## Bonnes pratiques | ||
| + | |||
| + | Voir : | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | |||
| + | Quand cela est possible préférer `COPY` à `ADD`. Voir https:// | ||
| + | |||
| + | Immediately before your ENTRYPOINT or CMD directive, you then add a USER | ||
| + | |||
| + | |||
| + | Ne pas utiliser `sudo` mais `gosu` ou `su-exec` | ||
| + | |||
| + | |||
| + | ### Vérif Dockerfile Conrainerfile avec Hadolint | ||
| + | |||
| + | Voir : | ||
| + | * https:// | ||
| + | |||
| + | ~~~bash | ||
| + | podman run --rm -i docker.io/ | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ## Exemple de Dockerfile et script | ||
| + | |||
| + | https:// | ||
| + | |||
| + | `start.sh` | ||
| + | ~~~bash | ||
| + | #!/bin/bash | ||
| + | set -e | ||
| + | |||
| + | # When docker restarts, this file is still there, | ||
| + | # so we need to kill it just in case | ||
| + | [ -f / | ||
| + | |||
| + | _kill_procs() { | ||
| + | kill -TERM $node | ||
| + | kill -TERM $xvfb | ||
| + | } | ||
| + | |||
| + | # Relay quit commands to processes | ||
| + | trap _kill_procs SIGTERM SIGINT | ||
| + | |||
| + | Xvfb :99 -screen 0 1024x768x16 -nolisten tcp -nolisten unix & | ||
| + | xvfb=$! | ||
| + | |||
| + | export DISPLAY=:99 | ||
| + | |||
| + | dumb-init -- node ./ | ||
| + | node=$! | ||
| + | |||
| + | wait $node | ||
| + | wait $xvfb | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | `Dockerfile` | ||
| + | ~~~ | ||
| + | CMD [" | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Buildha | ||
| + | |||
| + | voir https:// | ||
| + | |||
| + | docker build | ||
| + | |||
| + | ~~~bash | ||
| + | buildah bud -t myapp: | ||
| + | ~~~ | ||
| + | |||
| + | L' | ||
| + | |||
| + | |||
| + | |||
| + | ## Modification d' | ||
| + | |||
| + | ~~~ | ||
| + | # Copier nginx vers la registry locale | ||
| + | crane copy nginx: | ||
| + | |||
| + | # Aplatir l' | ||
| + | crane flatten localhost: | ||
| + | -t localhost: | ||
| + | ~~~ | ||
| + | |||
| + | Source : https:// | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ## Autres | ||
| + | |||
| + | `RUN apk add --no-cache shadow` | ||
| + | |||
| + | |||
| + | ~~~bash | ||
| + | export DOCKER_BUILDKIT=0 | ||
| + | |||
| + | ~~~ | ||
