Docker-compose 卷模式选项

Moh*_*wab 3 docker docker-compose cookiecutter-django

在简短的语法中,source:target:mode官方文档只提到了roand ,rw但在django 的 cookiecutter 模板中,他们使用了其他两种模式:zand Z,我在任何地方都没有找到它们的任何参考,它们是什么?

Dav*_*aze 5

Docker运行参考文档:

-v, --volume=[host-src:]container-dest[:<options>]: Bind mount a volume.
The comma-delimited `options` are [rw|ro], [z|Z],
[[r]shared|[r]slave|[r]private], and [nocopy].
The 'host-src' is an absolute path or a name value.

If neither 'rw' or 'ro' is specified then the volume is mounted in
read-write mode.

The `nocopy` mode is used to disable automatically copying the requested volume
path in the container to the volume storage location.
For named volumes, `copy` is the default mode. Copy modes are not supported
for bind-mounted volumes.
Run Code Online (Sandbox Code Playgroud)

这些选项在(指定的)卷文档(特别是ro)和绑定安装文档中进行了进一步记录。

在实践中,我从来不需要任何这些选项,除非我碰巧部署到启用了 SELinux 的系统,那么这些选项z很有用。

  • “z”和“Z”的具体文档在这里:https://docs.docker.com/storage/bind-mounts/#configure-the-selinux-label (2认同)