Continuing with docker lesson at https://www.youtube.com/watch?v=9zUHg7xjIqQ&t=1596s
You don’t even need to copy
node_modulesover to your docker image. Remember to use a
.dockerignoreas basic one looks like this:
- 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
-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
This mean can use the following cli flag when running the container `docker run -env PORT=<PORT-number>`