Reputation: 3
I use Docker Toolbox for windows (for compatibility issues) and in the Dockerfile I specify an ARG
so that I can use it when building the image with --build-arg
command. Inside the dockerfile I also have some COPY
commands and there I would like to use my variable but when I run docker build --build-arg VERSION_APP=something
. it does not translate the variable . I have already used $VERSION_APP
or ${VERSION_APP}
or %VERSION_APP%
.
FROM alpine
MAINTAINER Marinos
ARG VERSION_APP
RUN apk update && apk add dos2unix
COPY script.sh /home/script.sh
RUN chmod a+x /home/script.sh
RUN dos2unix /home/script.sh
RUN sh /home/script.sh
COPY installation.txt /home/Desktop/${VERSION_APP}
UPDATE
It seems that you should pass the whole path to the variable you use that is how I got it working.
Upvotes: 0
Views: 6463
Reputation: 11950
If you actually use the command below then it is expected not to work because the argument called VERSION_APP
docker build --build-arg myVar=something
So the command should be
docker build --build-arg VERSION_APP=something
And in Dockerfile it should be %VERSION_APP%
also you may need to use ENV like below:
ARG VERSION_APP
ENV VERSION_APP ${VERSION_APP}
Upvotes: 4