Based on:
https://shekhargulati.com/2019/01/18/dockerizing-a-vue-js-application/
I am trying to run a container that supports hot reload. According to above guide that should be possible with running the docker run command:
docker run -it -p 8081:8080 -v ${PWD}:/app/ -v /app/node_modules --name CONTAINER_NAME FRONTEND_IMAGE
But I don't understand this part: -v ${PWD}:/app/ -v /app/node_modules
. Looking at the first part:
-v ${PWD}:/app/
According to the documentation:
https://docs.docker.com/storage/bind-mounts/
the first parameter to -v
is the name of the volume. Why would you select the name ${PWD}
as the name? In my case that ends up being: /home/user/code/sample001
In the second case:
-v /app/node_modules
the volume does not even have a name. Comparing that with example from the docker docs:
$ docker run -d \
--name devtest \
-v myvol2:/app \
nginx:latest
I don't see how -v /app/node_modules
even makes sense.
If I then do:
$ docker inspect CONTAINER_NAME
...
"HostConfig": {
"Binds": [
"/home/user/code/sample001:/app/"
],
...
"Mounts": [
{
"Type": "bind",
"Source": "/home/user/code/sample001",
"Destination": "/app",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "volume",
"Name": "83cbd979484473e3a5a258b8dbad052bc8927e207aa2dc4afa73be72113d3102",
"Source": "/var/lib/docker/volumes/83cbd979484473e3a5a258b8dbad052bc8927e207aa2dc4afa73be72113d3102/_data",
"Destination": "/app/node_modules",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
],
-v ${PWD}:/app/
actually creates a bind and not a volume.
What am I missing?