Docker Community Forums

Share and learn in the Docker community.

Help with build argument --build-arg and ARG

build

(Quentin McGaw) #1

Hi all,

I am having troubles understanding build arguments.

I build the image with:

docker build -t mycaddy --build-arg x=zzzz ./

My Dockerfile (to test):

FROM alpine
RUN echo ${x} # nothing
ARG x=test
RUN echo ${x} # nothing
ENV y=${x}
RUN echo ${y} # this shows zzzz

How can I access x without setting another environment variable y? Thanks !!