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

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

    The trick is to recognize that you can specify the context in the build command to include files from the parent directory if you specify the Docker path, I'd change my Dockerfile to look like this:

    ...
    COPY ./ /dest/
    ...
    

    Then my build command can look like this:

    docker built -t TAG -f DOCKER_FILE_PATH CONTEXT
    

    From the project directory

    docker built -t username/project[:tag] -f ./docker/Dockerfile .
    

    From project/docker

    docker built -t username/project[:tag] -f ./docker/Dockerfile ..
    

提交回复
热议问题