docker-compose 的上下文或工作目录

新手上路,请多包涵

我正在学习码头工人

我需要为 docker 映像指定工作目录,我认为这将是这样的:

 version: '2'
services:
  test:
    build:
      context: ./dir

Now I want to make the image python:onbuild to run on the ./dir , but I dont want to create any Dockerfile inside the ./dir .

docker-compose 手册对此只字未提。

可能吗?怎么做?

原文由 Roomy 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 468
2 个回答

您可以按如下方式指定工作目录。

 version: '2'
services:
  test:
    build:
      context:    /path/to/source/dir/
      dockerfile: /path/to/custom-Dockerfile/relative/tocontextdir/Dockerfile
    working_dir: /app

原文由 Ian Purton 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题