繁体   English   中英

如何使用 docker 组合将主机目录作为卷安装在 docker 容器中

[英]How to mount a host directory as volume in docker container using docker compose

我有一个目录models ,其中包含 4 个文件。 我正在尝试将其作为卷安装在我的容器中,如下所示:

volumes:
    - /home/andrew/Documents/models/:/home/andrew/Documents/models/

但它一直向我抛出这个错误:

"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type ERROR: Encountered errors while bringing up the project.

我使用的是 docker-compose 的 2.4 版。 谁能告诉我这有什么问题。 谢谢

如果你必须更新你的语法。 简短的语法是: [SOURCE:]TARGET[:MODE]格式。 TARGET是安装卷的容器路径。

  # Path on the host, relative to the Compose file
  - ./cache:/tmp/cache

  # User-relative path ~ == /home/username And  container path where the volume is mounted
  - ~/configs:/var/lib/:ro

撰写卷 - 版本 2 参考]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM