Docker nodeJS node
My notes on using Git, NodeJS with official docker image:
- When you use -v / --volume, the directory will be created if not exists
- Bear in mind: NodeJS DID NOT have a server. Unlike Apache. So it is OK to use -v to mount a directory directly and run npm install and npm start
- To start: git clone <url> <target_dir>
- run the docker-compose.yml by running: sudo docker-compose -f <path_to_my_docker-compose.yml> up.
- In the above command, you can add '-d' at the end to run it on background.
- In docker-compose, if you want to run multiple commands, run this: command: bash -c "your_command" (reference).
- If you prefer using native docker statement: sudo docker run -it -d --name nodejs --rm -v <your_host_directory>:<your_docker_container_directory> -p 80:80 node:latest bash -c "npm install && npm start"
- Still not sure how to connect to webpack-dev-server inside container which the docker host is also a VM.
Comments