在绑定挂载“hostPath:containerPath:ro”中 ro 部分起什么作用?

在绑定挂载“hostPath:containerPath:ro”中 ro 部分起什么作用?
  1. 我怎么知道是否需要添加 ro?
  2. 我知道 ro 代表只读,但是为什么需要只读绑定挂载?
  3. 这会对我的 docker-composer-yml 产生什么影响

示例:容器化 Python 应用程序

// docker-composer.yml
...
volumes:
    - ./src:/usr/src/app/src:ro

答案1

ro方法read-onlyhttps://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)

相关内容