Dockerizing-a-Node.js-web-app

  • 1- Create the Node.js app
  • 2- reate a server.js file that defines a web app using the Express.js framework
  • 3- Creating a Dockerfile

you need to make this steps to run app

1- Building your image

  • $ docker build . -t /node-web-app
  • Your image will now be listed
  • image

2- Run the image

  • $ docker run -p 49160:8080 -d /node-web-app

3- If you need to Enter the container

  • $ docker exec -it /bin/bash

4- Now you can call your app using curl (install if needed via: sudo apt-get install curl):

  • $ curl -i localhost:49160
  • image
  • image

Shut down the image

4- Kill our running container

  • $ docker kill
  • Confirm that the app has stopped
  • $ curl -i localhost:49160
  • curl: (7) Failed to connect to localhost port 49160: Connection refused