0

I am attempting to achieve a setup with directories

/foo
/foo/bar

Where /foo/bar is a directory mounted from the local file system but /foo is not. I would like /foo/bar to be read-only, but /foo to be read-write. Is this achievable in Docker?

user1336958
  • 105
  • 2
  • 10

1 Answers1

2

Well, heck, let's try it.

$ 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

So it looks like the answer is, "yes."

larsks
  • 277,717
  • 41
  • 399
  • 399