-
Continuing with docker lesson at https://www.youtube.com/watch?v=9zUHg7xjIqQ&t=1596s
-
You don’t even need to copy
node_modules
over to your docker image. Remember to use a.dockerignore
as basic one looks like this:
node_modules
Dockerfile
.dockerignore
.git
.gitignore
- If we want to use docker for local dev, changes don’t come to get synced magically. a new image needs to be rebuilt and run every time. A workaround for this is to use a bind mount volume. The full cmd would look something like:
docker run -v <full-path-from-host>:<docker-path> -p 1234:3000 -d --name node-app node-app-image
- if we want the bind mount to be read-only we can use
ro
-v <full-path-from-host>:<docker-path>:ro
.
this means docker cant create new files on the host machine.
- To use environment variables set by a user we can use the
$
syntax in our Dockerfile
EXPOSE $PORT
This mean can use the following cli flag when running the container `docker run -env PORT=<PORT-number>`