I have a docker container which is launched with docker-compose.yml which contains
service: my-service
volumes:
- /tmp/mount/opt/my-app:/opt/my-app
There are symlinks in /tmp/mount/opt
e.g. /tmp/mount/opt/my-app/test1.cfg
which points to /host/path/test1.cfg
When the container starts up, it fails with an error like:
my-service | Failed to stat config file "/opt/my-app/test1.cfg": No such file or directory
However if I docker exec -ti the_same_container bash
and cat /opt/my-app/test1.cfg
then I see exactly the expected contents.
Also if on the host I run cp -r -L /tmp/mount /tmp/mount_copy
and modify the yml
service: my-service
volumes:
- /tmp/mount_copy/opt/my-app:/opt/my-app
then everything works.
In other words, the symlink in the mounted directory can be read by the container after it starts up, but not during, and mounting a non-symlinked clone of the directory is fine.
Why are symlinks behaving like this in docker?