tech:docker_image_build
Table des matières
Docker image build
Voir :
Ansible :
Outils / Méthode / Container Image Builders :
- Docker / Dockerfile
- Buildah
- openshift-imagebuilder
- S2I
- CNB
- Paketo
- umoci
Bonnes pratiques
Voir :
Quand cela est possible préférer COPY à ADD. Voir https://docs.docker.com/build/building/best-practices/
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 :
podman run --rm -i docker.io/hadolint/hadolint < Dockerfile
Exemple de Dockerfile et script
https://github.com/browserless/chrome/blob/master/start.sh
start.sh
#!/bin/bash set -e # When docker restarts, this file is still there, # so we need to kill it just in case [ -f /tmp/.X99-lock ] && rm -f /tmp/.X99-lock _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 ./build/index.js $@ & node=$! wait $node wait $xvfb
Dockerfile
CMD ["./start.sh"]
Buildha
voir https://www.grottedubarbu.fr/buildah-basics/
docker build
buildah bud -t myapp:latest .
L'option bud est en réalité une version courte de l'option build-using-dockerfile
Modification d'image
# Copier nginx vers la registry locale crane copy nginx:1.27.3-alpine localhost:5000/nginx:1.27.3-alpine --platform linux/amd64 # Aplatir l'image crane flatten localhost:5000/nginx:1.27.3-alpine \ -t localhost:5000/nginx:1.27.3-alpine-flat
Source : https://blog.stephane-robert.info/docs/conteneurs/outils/crane/
Autres
RUN apk add --no-cache shadow
export DOCKER_BUILDKIT=0
tech/docker_image_build.txt · Dernière modification : de 127.0.0.1
