Dockerizing a Node.js web application

1. Create the Node.js app

2. Creating a Dockerfile

3. Building your image

docker build . -t hello-docker-world
$ docker images hello-docker-world

# Example
node 10 1934b0b038d1 5 days ago
<your username>/node-web-app latest d64d3505b0d2 1 minute ago

4. Run the image

docker run --name c1 -p 80:8080 -d hello-docker-world
docker ps
# Get container ID
$ docker ps

# Print app output
$ docker logs <container id>
# Example
Running on http://localhost:8080
# Enter the container
$ docker exec -it <container id> /bin/bash



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Udara Vimukthi

Udara Vimukthi

Final Year Undergraduate, University of Moratuwa.