Using docker to build a node.js app, then push it on Docker Hub.
This repository contains:
- The simple-node.js-app
Prerequisite:
- Docker on the local machine
- Docker Hub account
- Dockerfile (Dockerfile is needed to be suitable for the platform you are using)
Step 1: Build the application with the docker
Change directory to the root directory of the node.js application
cd /path-to-node.js-app/
Build and tag the application
docker build -t bongu1302/demo:v2 .
Check whether the application is built or not:
docker images
Step 2: Run the application
docker run -d -p 8080:8080 bongu1302/demo:v1
Notes that -d is run docker in background, flag -p stands for port
Check container is running or not, When the app is built, it is called an image, when we run the image, it is called the container
docker ps
Step 3: Push the image to Docker Hub
docker push bongu1302/demo:v1
MIT © HuynhTanPhat