我正在使用docker run挂载一个文件: 这很好用:
docker run -v /path/to/myconfig.conf:/path/.to/myconfig.conf ..
但是在码头工作中,它正在抱怨:
volumes:
- named-volume:/path
- ./path-in-project/myconfig.conf:/path/.to/myconfig.conf
错误:
Cannot start service xxx: oci runtime error: container_linux.go:262: starting container process caused "process_linux.go:339: container init caused \"rootfs_linux.go:57: mounting \\\"/path/to/my/myconfig.conf\\\" to rootfs \\\"/var/lib/docker/aufs/mnt/249085892d6539519b0271c1490f23529c7bcaxxx5a471cc256ed83a6f4d\\\" at \\\"/var/lib/docker/aufs/mnt/249085892d6539519b0271c1490f23529c7bcaxxx5a471cc256ed83a6f4d/path/.to/myconfig.conf\\\" caused \\\"not a directory\\\"\""
: 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
答案 0 :(得分:1)
如果问题与安装的顺序有关,则方法不正确。你不想处于
的境地volumes:
- named-volume:/path
- ./path-in-project/myconfig.conf:/path/.to/myconfig.conf
与
不同volumes:
- ./path-in-project/myconfig.conf:/path/.to/myconfig.conf
- named-volume:/path
因为docker-compose
或docker
的变化可能会发生变化。所以你应该做的是在你的Dockerfile符号链接中/path/.to/myconfig.conf
到/config/myconfig.conf
然后在您的docker卷中使用
volumes:
- ./path-in-project/myconfig.conf:/config/myconfig.conf
- named-volume:/path
答案 1 :(得分:0)
我的问题是顺序。首先我必须将文件挂载到容器中,然后我必须保持我的约会日期:
不起作用:
volumes:
- named-volume:/path
- ./path-in-project/myconfig.conf:/path/.to/myconfig.conf
工作:
volumes:
- ./path-in-project/myconfig.conf:/path/.to/myconfig.conf
- named-volume:/path