dockerInstructions stage
docker:
  VOLUME:
  - <volume>
  EXPOSE:
  - <expose>
  ENV:
    <env_name>: <env_value>
  LABEL:
    <label_name>: <label_value>
  ENTRYPOINT: <entrypoint>
  CMD: <cmd>
  WORKDIR: <workdir>
  USER: <user>
  HEALTHCHECK: <healthcheck>

Dockerfile instructions can be divided into two groups: build-time instructions and other instructions affecting an image manifest. Build-time instructions do not make sense in a werf build process. Thus, werf supports only following instructions:

  • USER to set the user name (or UID) and optionally the user group (or GID) (read more here).
  • WORKDIR to set the working directory (read more here).
  • VOLUME to add a mount point (read more here).
  • ENV to set the environment variable (read more here).
  • LABEL to add metadata to an image (read more here).
  • EXPOSE to inform Docker that the container listens on the specified network ports at runtime (read more here)
  • ENTRYPOINT to configure a container that will run as an executable (read more here). How the Stapel builder processes CMD and ENTRYPOINT is covered here.
  • CMD to provide the default arguments for the ENTRYPOINT to configure a container that will run as an executable (read more here). How the Stapel builder processes CMD and ENTRYPOINT is covered here.
  • HEALTHCHECK to tell Docker how to test a container to see if it is still working (read more here)

These instructions can be specified in the docker config directive.

Here is an example of using Docker instructions:

docker:
  WORKDIR: /app
  CMD: ["python", "./index.py"]
  EXPOSE: '5000'
  ENV:
    TERM: xterm
    LC_ALL: en_US.UTF-8

The Docker instructions defined in the configuration are applied during the last stage called docker_instructions. Thus, instructions do not affect other stages but are applied to a built image.

If you need to use specific environment variables at build time (such as a TERM environment), you have to use the base image in which these environment variables are set.

Tip: you can also export environment variables right to the user stage instructions.