在Docker中安装卷时,“只读”标志的范围
我正在尝试实现与目录的设置
/foo /foo/bar
其中/foo/bar
是从本地文件系统挂载的目录,但/foo
不是。 我想/foo/bar
是只读的,但/foo
是可读写的。 在Docker中可以实现吗?
那么,嘿,我们试试吧。
$ mkdir /tmp/data $ docker run -it --rm -v /tmp/data:/foo/bar:ro busybox sh / # cd /foo /foo # echo look I can write files here > testfile /foo # cd bar /foo/bar # echo but here not so much > testfile sh: can't create testfile: Read-only file system
所以看起来答案是“是”。