我想在运行以下命令时将容器的根文件系统挂载为只读:
docker ps --quiet --all | xargs docker inspect --format '{{ .Id }}: ReadonlyRootfs={{ .HostConfig.ReadonlyRootfs }}'
如果上面的命令返回'true',则表示根文件系统以只读方式挂载。如果上面的命令返回'false',则表示根文件系统是可写的。
当我运行命令时,ReadonlyRootfs=false
正在显示
请帮忙。
谢谢。
将--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