- 我怎么知道是否需要添加 ro?
- 我知道 ro 代表只读,但是为什么需要只读绑定挂载?
- 这会对我的 docker-composer-yml 产生什么影响
示例:容器化 Python 应用程序
// docker-composer.yml
...
volumes:
- ./src:/usr/src/app/src:ro
答案1
ro
方法read-only
:
https://docs.docker.com/engine/reference/run/#volume-shared-filesystems
-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.
--volumes-from="": Mount all volumes from the given container(s)