Docker compose docker compose yml文件中的working_dir标记是什么意思

Docker compose docker compose yml文件中的working_dir标记是什么意思,docker-compose,dockerfile,Docker Compose,Dockerfile,只是想知道对于通过docker compose加载的图像,工作的_dir文件究竟做了什么。docker-compose.yml文件示例如下: dev: extends: file: common.yml service: workspace volumes: - $ATOMSPACE_SOURCE_DIR:/atomspace - $COGUTILS_SOURCE_DIR:/cogutils # Un

只是想知道对于通过docker compose加载的图像,工作的_dir文件究竟做了什么。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"

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

虽然有
docker compose.yml
,但您仍然有
Dockerfile
用于构建映像,对吗?工作目录下的内容是否保持不变?从我的小实验来看,我不这么认为。是否只是在启动映像后更改为特定目录的问题?是的,它所做的一切都会更改目录。如果该目录不存在,将创建它。它什么都不存在。您可以使用
volumes
来持久化数据。这是否意味着它与dockerfile中的WORKDIR相同或覆盖?或者,它仅在未提供docker文件且直接从docker compose文件中的docker hub图像实例化时使用?