Docker and symlinks

前端 未结 4 1216
别那么骄傲
别那么骄傲 2020-12-23 16:28

I\'ve got a repo set up like this:

/config
   config.json
/worker-a
   Dockerfile
   
   /code
/worker-b
   Dockerfile
   

        
4条回答
  •  孤城傲影
    2020-12-23 16:51

    The docker build CLI command sends the specified directory (typically .) as the "build context" to the Docker Engine (daemon). Instead of specifying the build context as /worker-a, specify the build context as the root directory, and use the -f argument to specify the path to the Dockerfile in one of the child directories.

    docker build -f worker-a/Dockerfile .
    docker build -f worker-b/Dockerfile .
    

    You'll have to rework your Dockerfiles slightly, to point them to ../config/config.json, but that is pretty trivial to fix.

    Also check out this question/answer, which I think addresses the exact same problem that you're experiencing.

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

    Hope this helps! Cheers

提交回复
热议问题