问题
I am mounting a directory from a CMS with content files inside a docker container.
The mounting works absolutely. The CMS got some basic files, which are copied into the mounted folder in the container during build. Then it will be mounted to a directory on the host. Now the files from the Container are also on the host. I can change them and they will be kept in sync.
If i restart my container docker-compose stop
&& docker-compose up -d
the files on the host will be overwritten by the default ones from the container build.
Is there a possibility to force the local state of the file to overwrite the file in the container?
Kind regards
回答1:
maybe try configuring it as read only
docker run -v volume-name:/path/in/container:ro my/image
回答2:
You can set it as read only as gCoh answer. See the following for docker-compose:
volumes:
- type: bind
source: ./host-source-folder
target: /container-folder
read_only: true
来源:https://stackoverflow.com/questions/51534907/docker-compose-mount-volume-overwrites-host-files