【问题标题】:What does working_dir tag mean in a docker-compose yml filedocker-compose yml文件中的working_dir标签是什么意思
【发布时间】:2016-10-31 12:12:11
【问题描述】:

只是想知道 working_dir 文件对通过 docker-compose 加载的图像真正做了什么。一个示例 docker-compose.yml 文件如下:

dev:
    extends:
        file: common.yml
        service: workspace
    volumes:
        - $ATOMSPACE_SOURCE_DIR:/atomspace
        - $COGUTILS_SOURCE_DIR:/cogutils
        # Uncomment the following lines if you want to work on moses
        # - $MOSES_SOURCE_DIR:/moses
    working_dir: /opencog # This is the same as the volume mount point below
    links:
        - postgres:db
        - relex:relex

postgres:
    image: opencog/postgres
    # Uncomment the following lines if you want to work on a production
    # system.
    # NOTE: The environment variable `PROD` is set `True` then the entrypoint
    # script in opencog/postgres does additional configurations.
    # environment:
    #     - PROD=True

relex:
    image: opencog/relex
    command: /bin/sh -c "./opencog-server.sh"

【问题讨论】:

  • 虽然有docker-compose.yml,但你还是有Dockerfile来构建镜像的吧?

标签: docker-compose dockerfile


【解决方案1】:

working_dir 设置创建的容器的工作目录。它与--workdir 标志到docker run 相同。

【讨论】:

  • working_dir下的内容是否持久化?从我的小实验来看,我不这么认为。只是启动镜像后切换到特定目录的问题吗?
  • 是的,它所做的就是改变目录。如果该目录尚不存在,则会创建该目录。它不坚持任何东西。您可以使用volumes 来持久化数据。
  • 这是否意味着它与/或覆盖dockerfile中的WORKDIR相同?还是仅在未提供 dockerfile 并且您直接从 docker-compose 文件中的 docker hub 图像实例化时使用?
猜你喜欢
  • 2012-01-29
  • 2021-07-21
  • 2019-09-17
  • 1970-01-01
  • 2016-01-31
  • 1970-01-01
  • 1970-01-01
  • 2011-01-20
相关资源
最近更新 更多