Dockers - 将容器的根文件系统挂载为只读

问题描述 投票:0回答:1

我想在运行以下命令时将容器的根文件系统挂载为只读:

docker ps --quiet --all | xargs docker inspect --format '{{ .Id }}: ReadonlyRootfs={{ .HostConfig.ReadonlyRootfs }}'

如果上面的命令返回'true',则表示根文件系统以只读方式挂载。如果上面的命令返回'false',则表示根文件系统是可写的。

当我运行命令时,ReadonlyRootfs=false正在显示

请帮忙。

谢谢。

mount
1个回答
0
投票

--read-only标志传递给docker run命令时,根文件系统以只读方式挂载,例如:

$ docker run -it --read-only centos [root@87e0f56dc341 /]# touch test touch: cannot touch 'test': Read-only file system

帮助页面: $ docker run --help | grep read-only --read-only Mount the container's root filesystem as read only

© www.soinside.com 2019 - 2024. All rights reserved.