Hi all,
I’ve searched for this, but cannot seem to find an answer (my description/search term is probably poor, but I’m struggling to think of more apt phrasing. Apologies in advance.).
- I have a
docker-compose.yml
file with two containers that share an ‘./app’ source volume that requires different config files. - These config files are binding into that existing ‘./app’ volume (that is shared between both containers).
- When launching
docker-compose up
, the files are being copied into the./app
volume (with one container’s configs taking precedence over the other).
This is for a development environment (using node:v16 image) whereby I need these two containers to communicate with each other (albeit with different configurations).
Relevant portions of my docker-compose.yml
:
# Container 1
volumes:
- ./app:/home/node/app # Note that this is same source mount as Container 2
- ./.docker/container1/.env:/home/node/app/.env
- ./.docker/container1/database.db:/home/node/app/database.db
# Container 2
volumes:
- ./app:/home/node/app # Note that this is same source mount as Container 1
- ./.docker/container2/.env:/home/node/app/.env
- ./.docker/container2/database.db:/home/node/app/database.db
Is it possible with docker/docker-compose to make it so that the .env
and the database.db
files (from Container 1 or Container 2) do not land in the ./app
folder on my local machine and exist isolated from each other?
I realize this could also be resolved by mounting the .env
and database.db
in a different directory on each container (e.g. /var/app/.env
and /var/app/database.db
), but the app does not currently have the capability to configure read from different locations (these files must be placed in the app directory).
Any help/guidance on this would be much appreciated.
Thanks all.