Right now I am defining ARGs in my Dockerfile like this:
ARG CDN_ENDPOINT
ARG AWS_S3_BUCKET
Is there a way to define them in a single line similar to ENV to avoid creating extra layers in docker image like this:
ENV CDN_ENDPOINT=endpoint \
AWS_S3_BUCKET=bucket
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With