In this article as we begin to progress forward with deploying containers I wanted to build on previous articles. In this article we will create a package.json and server.js file, create a Dockerfile and see if our web app works.
Now let’s create a directory for our project:

$ mkdir <name_of_project>
$ cd <DIR>
Deploy web app running on a Docker Container
In this article as we begin to progress forward with deploying containers I wanted to build on previous articles. In this article we will create a package.json and server.js file, create a Dockerfile and see if our web app works.
Now let’s create the package.json file – use the editor of your choice

{
"name": "yankees_web_app",
"version": "1.0.0",
"description": "Node.js on Docker",
"author": "Paul Bryant",
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"dependencies": {
"express": "^4.16.1"
}
}

Now let’s create the server.js file – once again use the editor of your choice
'use strict';
const express = require('express');
// Constants
const PORT = 8080;
const HOST = '0.0.0.0';
// App
const app = express();
app.get('/', (req, res) => {
res.send('New York Yankees are the best team in baseball history');
});
app.listen(PORT, HOST);
console.log(`Running on http://${HOST}:${PORT}`);

$ npm install
Now let’s build the Dockerfile

FROM node
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 8080
CMD [ “node”, “server.js” ]

Create a .dockerignore file and put the following into it:
node_modules
npm-debug.log

Now let’s build the image
$ docker build -t pbryant/yankees-web-app .

$ docker run -p 8080:8080 pbryant/yankees-web-app:latest

As you can see we have gotten our intended results and can hit the webpage from our internal network on port 8080
What if we wanted to make a change to our webpage and have it updated in Docker?

Edit the server.js file with whatever you want to add

Rebuild the image – this is a requirement

Run the container based off the updated image

As you can see the changes made that we made have been updated
Summary:
I hope this quick walkthrough of a project format helped further your understanding of Docker. As always, I hope y’all found this useful.