Dockerfile

· 1 min read · Containers and Orchestration · Tool

A Dockerfile lists the instructions that docker build follows to create an image. Each instruction (FROM, COPY, RUN, USER, CMD...) adds a layer, and Docker caches the layers that did not change.

Key concepts #

  • FROM chooses the base image, and several FROM lines create a multi-stage build.
  • Build cache: put the instructions that change rarely first.
  • .dockerignore keeps files and secrets out of the build context.
  • CMD and ENTRYPOINT define what the container runs.
  • BuildKit adds cache mounts, secret mounts and multi-platform builds. See BuildKit and buildx.

Learn it #

Dockerfile tutorial.

More tutorials that use Dockerfile

#Docker #Dockerfile