测试环境用下面这个 docker-compose.yml 即可
services:
ubuntu:
image: ubuntu:22.04
volumes:
# - volumeetc:/etc
- ./data/etc:/etc
command: tail -f /dev/null
volumes:
volumeetc:
我的问题是:
如果使用 数据卷 volumeetc
挂载到 容器 /etc
目录, 启动容器后, 这个数据卷里的数据是完整的 etc 目录内的数据;
如果使用宿主机目录比如 ./data/etc 挂载到容器内, 宿主机 ./data/etc 这个目录下的数据不完整, 只有 hostname, hosts, resolv.conf 这三个文件;
我在 linux, mac, windows 都测试过, 都是这个行为;
调整过宿主机目录相关权限, 尽量和容器内保持一致, 也不行
我的问题是 为什么会有这种差异?
我个人推测跟容器创建的初始化流程有关, 但是没找到什么文档
希望大佬指条路
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.