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

Docker build passing command-line argumens

We can defined command-line parameters in the Dockerfile and then allow the user who builds the image to pass in values on the command line of docker build.

FROM ubuntu:22.04

ARG TEXT=foo

RUN echo "Hello" > welcome.txt
RUN echo $TEXT >> welcome.txt

docker build -t mydocker --build-arg TEXT=Bar .