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

前端 未结 14 1197
情话喂你
情话喂你 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:32

    The best way to work around this is to specify the Dockerfile independently of the build context, using -f.

    For instance, this command will give the ADD command access to anything in your current directory.

    docker build -f docker-files/Dockerfile .
    

    Update: Docker now allows having the Dockerfile outside the build context (fixed in 18.03.0-ce, https://github.com/docker/cli/pull/886). So you can also do something like

    docker build -f ../Dockerfile .
    

提交回复
热议问题