A docker container has these files and directories:
/foo//foo/a.txt/foo/subdir-1//foo/subdir-1/b.txt
The host has these files and directories:
/bar//bar/a.txt/bar/subdir-1//bar/subdir-1/c.txt
I want to mount the host's /bar
onto the container's /foo
such that the result will be the following in the container:
/foo//foo/a.txt/foo/subdir-1//foo/subdir-1/b.txt/foo/subdir-1/c.txt
such that the container sees the host's version of a.txt
, and similarly with other colliding file names. Colliding directories are merged such that the container sees the contents of both.
Furthermore, I want
- if
/bar/a.txt
or/bar/subdir-1/c.txt
are modified on the host, these modifications are immediately visible in the container - if a new file
/bar/subdir-1/d.txt
or a new subdirectory/bar/subdir-2
are created in the host while the container is running, the container will also see these appear
The host and container are both Linux.
I tried this in docker-compose:
volumes: - /bar:/foo
but my container no longer saw b.txt
since that file is not present in the host.
Is this effect possible using docker-compose?