问题
I'm trying to mount a writable Docker volume as a child of a read-only volume, but I get this error:
ERROR: for wordpress rpc error: code = 2 desc = "oci runtime error:
could not synchronise with container process: mkdir /mnt/sda1/var/lib
/docker/aufs/mnt/.../var/www/html/wp-content/uploads: read-only file
system"
I'm working with a WordPress image, and the two volumes I want to mount are:
- /var/www/html/wp-content: Contains my development code. Read-only, since I don't want any unexpected changes.
- /var/www/html/wp-content/uploads: Files that are uploaded by users. Must be writable.
The quick solution is to move uploads somewhere else, but I'd prefer a Docker solution.
Relevant bits of my docker-compose.yml:
volumes:
uploads:
driver: local
services:
wordpress:
volumes:
- /dev/workspace/wp-content/:/var/www/html/wp-content/
- uploads:/var/www/html/wp-content/uploads
回答1:
Answering my own question: The mount point must exist in the Read-Only volume, even if it won't be used. Docker was trying to create the uploads directory in the RO volume before mounting it.
When I created an empty directory at /dev/workspace/wp-content/uploads, the error disappeared and everything worked as expected.
回答2:
Yes, in general, you can! Here is an example with the read-only parent path
-v $DIR/htdocs:/var/www/html:ro
and another mount
-v $DIR/logs:/var/www/html/app/cache:rw
See more https://stackoverflow.com/a/37730878/4986182
来源:https://stackoverflow.com/questions/37883895/can-i-have-a-writable-docker-volume-mounted-under-a-read-only-volume