While searching for a docker-compose file I came across this. I saw that the volumes having 2 instructions I'm pretty sure that 2nd one is mapping but I don't know what's the 1st one.
volumes:
- /app/node_modules
- ./server:/app
I
While searching for a docker-compose file I came across this. I saw that the volumes having 2 instructions I'm pretty sure that 2nd one is mapping but I don't know what's the 1st one.
volumes:
- /app/node_modules
- ./server:/app
I
From the docker-compose reference on volumes short-syntax the first format you mentioned - /app/node_modules
follows the format SOURCE:]TARGET[:MODE]
, where you are only providing the TARGET
(the path in the container).
When the source is omitted, an anonymous volume is created, meaning the Docker volume will be created for you with a random name. Basically, a volume in the Docker filesystem will be created and mounted to your container at the path /app/node_modules
. This is useful if you want to later re-mount and share data between containers like in this example in the docs.
You can read more about Docker volumes here: https://docs.docker.com/storage/volumes/