Dockerfile define multiple ARG arguments in a single line

After testing this by creating the ARGs similar to ENV like this:

ARG CDN_ENDPOINT \
    AWS_S3_BUCKET

I got this error:

ARG requires exactly one argument definition

So judging from that, the ARG command only allows one argument. So its impossible to define multiple ARGs in a single line inside dockerfile.


On a different note, ARG does not go in the build image. So may be, one should not worry about the layers caused by ARG.


To achieve what you want you have to do this:

in your Dockerfile define the ARG variables you need with a default value (so, in case you don't pass it it can still work):

ARG P_TAG=8-jdk
FROM openjdk:${P_TAG}

ARG P_VERSION="1.22.2-stable"

ENV TAG=${P_TAG}
ENV VERSION=${P_VERSION}

RUN echo TAG=${TAG}
RUN echo VERSION=${VERSION}

Then your build line should go like this:

docker build --build-arg P_TAG=11-jdk --build-arg P_VERSION=2.0.4-stable

You need to be sure that your dockerfile contains as ARG all the variables you need to pass.