- Prepare the image:
$ docker build --tag node-docker .
Note: Use with --network host
if the above command fails to install npm packages.
- Run the container:
$ docker run --publish 127.0.0.1:3000:8080 --name first-app node-docker
Running on http://0.0.0.0:8080
Brought by docker
Note: You can use whatever --name
and whichever host address instead of first-app
and 127.0.0.1:3000
you want.
-
Open a browser at http://127.0.0.1:3000 and see the server running
-
Stop the container and thus, the server with:
$ docker stop first-app
- Install depedencies:
$ npm install
- Run the server locally with:
$ node server.js --host=127.0.0.1 --port=3000
Running on http://127.0.0.1:3000
Brought by <username>
- Stop the server by pressing Ctrl+C.
Open a browser at http://127.0.0.1:3000 and see the server running