Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Instruction ENV

Summary

ENV <key>=<value> [...<key=value>]

The ENV instruction sets one or more environment variables inside the build namespace.

Important

The ENV instructions only affects building a container, not running a container.

Example:

ENV CFLAGS="--with-sprinkles"
ENV API_TOKEN="acbd18db4cc2f85cedef654fccc4a4d8" API_USER="user@example.org"

The ENV instruction affects all instructions that come after it, in the same layer.

It is possible to overwrite a value that has been set previously:

FROM docker://busybox

ENV HITCHHIKER="Arthur Dent"
RUN sh -c "echo $HITCHHIKER" # outputs "Arthur Dent"

ENV HITCHHIKER="Ford Prefect"
RUN sh -c "echo $HITCHHIKER" # outputs "Ford Prefect"