How to include files outside of Docker's build context?

前端 未结 14 1067
情话喂你
情话喂你 2020-11-22 07:21

How can I include files from outside of Docker\'s build context using the \"ADD\" command in the Docker file?

From the Docker documentation:

T

14条回答
  •  醉梦人生
    2020-11-22 07:39

    In my case, my Dockerfile is written like a template containing placeholders which I'm replacing with real value using my configuration file.

    So I couldn't specify this file directly but pipe it into the docker build like this:

    sed "s/%email_address%/$EMAIL_ADDRESS/;" ./Dockerfile | docker build -t katzda/bookings:latest . -f -;
    

    But because of the pipe, the COPY command didn't work. But the above way solves it by -f - (explicitly saying file not provided). Doing only - without the -f flag, the context AND the Dockerfile are not provided which is a caveat.

提交回复
热议问题