Docker Community Forums

Share and learn in the Docker community.

One-way sync bind mounts

I have a docker-compose file that creates a basic bind mount, it creates a bind mount between the host directory and the container directory.

/mnt/data:/var/lib/eg

When my container boots up, the files that are present in both the directories are copied over to each other as it is supposed to.

I wanted to know if there’s a way to create a one-way sync between the host directory and the container directory which causes the files that are present in the host directory to be passed over to the container directory but not vice-versa.
I’ve experimented with read-only bind mounts but it appears that it causes the container file system to be read-only which prevents the container from booting up.

Any suggestions on this would be greatly appreciated!