当我运行以下命令时,我希望将容器的根文件系统挂载为只读:
docker ps --quiet --all | \
xargs docker inspect \
--format '{{ .Id }}: ReadonlyRootfs={{ .HostConfig.ReadonlyRootfs }}'如果上面的命令返回true,则表示根文件系统是以只读方式挂载的。如果上面的命令返回false,则表示根文件系统是可写的。
当我运行该命令时,显示的是ReadonlyRootfs=false。如何让它显示true
发布于 2018-08-08 14:02:52
当您将标志--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 onlyhttps://stackoverflow.com/questions/49868801
复制相似问题