Docker build-arg and copy

You need to define it with ARG in Dockerfile before using:

FROM alpine:3.3

ARG folderVariable=./my-folder # Optional default value to be `./my-folder`

COPY ${folderVariable} /opt/my-folder

And build it like:

docker build --build-arg folderVariable=./folder-copy -t test .

More details please refer to: https://docs.docker.com/engine/reference/builder/#arg

Leave a Comment