arrow_back
Back

Dockerfile ARG: build-time variables

Andrew Dorokhov Andrew Dorokhov schedule 1 min read

ARG defines variables available only during the build stage.

ARG <NAME>=<DEFAULT_VALUE>

Example:

# Create an image for the weather-app
FROM node
LABEL org.label-schema.version=v1.1
ARG SRC_DIR=/var/node
RUN mkdir -p $SRC_DIR
ADD src/ $SRC_DIR
WORKDIR $SRC_DIR
RUN npm install
EXPOSE 3000
CMD ./bin/www

Pass values at build time with docker build --build-arg NAME=value.

code

Need Help with Development?

Happy to help — reach out via the contacts or go straight to my Upwork profile.

work View Upwork Profile arrow_forward
Next Article

Dockerfile ADD: copying files and remote URLs

arrow_forward