gpt4 book ai didi

Dockerfile 文件路径 : what does the colon mean?

转载 作者:行者123 更新时间:2023-12-02 18:20:06 26 4
gpt4 key购买 nike

在 Dockerfiles 和 docker-compose 文件中,我经常偶然发现两种符号。

docker 撰写示例:

volumes:
- ./app/:/usr/src/app/

示例 Dockerfile
COPY ./Pipfile /usr/src/app/Pipfile

第二种方法是,从我的机器目录 ./Pipfile 中获取文件/文件夹并将其复制到目录/usr/... 中的图像中?但是第一个是什么意思?

谢谢。

最佳答案

https://docs.docker.com/storage/images/types-of-mounts-volume.png

如果是 bind mount

-v or --volume: Consists of three fields, separated by colon characters (:).
The fields must be in the correct order, and the meaning of each field is not immediately obvious.

  • In the case of bind mounts, the first field is the path to the file or directory on the host machine.
  • The second field is the path where the file or directory is mounted in the container.
  • The third field is optional, and is a comma-separated list of options, such as ro, consistent, delegated, cached, z, and Z. These options are discussed below.


如果是 命名卷 : 第一个字段是卷的名称 , 并且在给定的主机上是唯一的。对于匿名卷,省略第一个字段。

这里:第一个参数是路径,/app/: 所以绑定(bind)挂载它是。

关于Dockerfile 文件路径 : what does the colon mean?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55155565/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com