Interview Prep/Docker/Dockerfile Instructions & Builds

How do Dockerfile variables and `${VAR:-default}` expansion work?

AdvancedConceptDockerfile Instructions & Builds
Answer

ARG and ENV can be referenced as $VAR or ${VAR} in ADD, COPY, ENV, EXPOSE, FROM, LABEL, USER, VOLUME, WORKDIR. Modifiers: ${VAR:-default} and ${VAR:+alt}. In RUN, CMD and ENTRYPOINT, expansion is done by the shell (shell form) or not at all (exec form).

All Docker questions Roadmap: Docker & containers

More on Dockerfile Instructions & Builds