Monday, August 24, 2026

Docker Images Push and Pull on Docker Hub

Simple Node.js Application + Deploy to Docker Hub

We will create a very simple Node.js web application, create a Docker image, and then upload (push) it to Docker Hub.


Step 1: Create a Project Folder

Open VS Code and create a folder:

node-docker-app

Inside it, create these files:

node-docker-app/

── server.js

── package.json

└── Dockerfile

 

Step 2: Create server.js

Add this simple Node.js code:

const http = require("http");

 

const server = http.createServer((req, res) => {

  res.writeHead(200, { "Content-Type": "text/html" });

  res.end("<h1>Hello from Node.js Docker App!</h1>");

});

 

server.listen(3000, () => {

  console.log("Server running on port 3000");

});

This program creates a small web server running on port 3000.

 

Step 3: Create package.json

{

  "name": "node-docker-app",

  "version": "1.0.0",

  "description": "Simple Node.js Docker application",

  "main": "server.js",

  "scripts": {

    "start": "node server.js"

  }

}

Since this simple application uses only Node.js built-in modules, we do not need any additional npm packages.

 

Step 4: Create a Dockerfile

Create a file named exactly:

Dockerfile

Add:

FROM node:alpine

WORKDIR /app

COPY . .

EXPOSE 3000

CMD ["node", "server.js"]


Simple Explanation

Command

Meaning

FROM node:alpine

Uses a lightweight Node.js image

WORKDIR /app

Creates/uses /app folder

COPY . .

Copies project files into the container

EXPOSE 3000

Declares port 3000

CMD

Starts the Node.js application

 

 

Step 5: Build the Docker Image

Open the terminal inside your project folder and run:

docker build -t node-docker-app .

Check the image:

docker images

 

Step 6: Run the Docker Container

docker run -d -p 3000:3000 --name node-app node-docker-app

Check the running container:

docker ps

Now open your browser:

http://localhost:3000

You should see:

Hello from Node.js Docker App!

 

 Step 7: Create a Docker Hub Account

Go to:

Docker Hub

Create an account if you do not already have one.

For example, suppose your Docker Hub username is:

your-dockerhub-username

 

Step 8: Login to Docker Hub

In the terminal, run:

docker login

Enter your Docker Hub username and password when requested.


Step 9: Tag Your Docker Image

Docker Hub needs your username in the image name.

Replace your-dockerhub-username with your actual Docker Hub username:

docker tag node-docker-app your-dockerhub-username/node-docker-app:latest

 

Example

If your username is sofficial333:

docker tag node-docker-app sofficial333/node-docker-app:latest

 

Check it:

docker images

Step 10: Push the Image to Docker Hub 🚀

Run:

docker push your-dockerhub-username/node-docker-app:latest

Example

docker push soffical333/node-docker-app:latest

Docker will upload your image to your Docker Hub repository.

Complete Flow

Create Node.js App

       

Create Dockerfile

       

docker build

       

Docker Image

       

docker run

       

Test on localhost:3000

       

docker login

       

docker tag

       

docker push

       

☁️ Docker Hub

 


Pull the Image on Another Computer

Anyone with access to the repository can download it using:

docker pull your-dockerhub-username/node-docker-app:latest

Then run it:

docker run -d -p 3000:3000 your-dockerhub-username/node-docker-app:latest

This is the basic workflow:

Create App → Build Image → Run Container → Tag Image → Push to Docker Hub → Pull and Run Anywhere.

 

Docker Hub

What is Docker Hub?

Docker Hub is an online platform where you can store, share, download, and manage Docker images.

Think of Docker Hub like GitHub, but for Docker images.


Simple Example

Suppose you create a website and package it into a Docker image:

my-website

You can upload this image to Docker Hub. Then you—or anyone with permission—can download and run it on another computer or server.


How Docker Hub Works

Create Application

              

Create Docker Image

              

Push Image to Docker Hub

              

Docker Hub ☁️

              

Pull Image on another system

             

Run Container


Main Docker Hub Commands

Command

Purpose

docker login

Log in to Docker Hub

docker push image-name

Upload an image to Docker Hub

docker pull image-name

Download an image from Docker Hub

docker search nginx

Search for Docker images


Example: Download and Run Nginx

docker pull nginx

docker run -d -p 80:80 nginx

 

Here, Docker downloads the Nginx image from Docker Hub and uses it to create a container.


In One Simple Line

Docker Hub is a cloud-based repository where developers can upload, store, share, download, and manage Docker images.


It is very useful in Docker, DevOps, CI/CD, cloud computing, and application deployment.




Simple Node.js Application Deploy to Docker Hub

Deploy to Docker Hub a Simple Node.js Application

We will create a very simple Node.js web application, create a Docker image, and then upload (push) it to Docker Hub.

Step 1: Create a Project Folder

Open VS Code and create a folder:

node-docker-app

Inside it, create these files:

node-docker-app/

── server.js

── package.json

└── Dockerfile

 

Step 2: Create server.js

Add this simple Node.js code:

const http = require("http");

 

const server = http.createServer((req, res) => {

  res.writeHead(200, { "Content-Type": "text/html" });

  res.end("<h1>Hello from Node.js Docker App!</h1>");

});

 

server.listen(3000, () => {

  console.log("Server running on port 3000");

});

This program creates a small web server running on port 3000.

 

Step 3: Create package.json

{

  "name": "node-docker-app",

  "version": "1.0.0",

  "description": "Simple Node.js Docker application",

  "main": "server.js",

  "scripts": {

    "start": "node server.js"

  }

}

Since this simple application uses only Node.js built-in modules, we do not need any additional npm packages.

 

Step 4: Create a Dockerfile

Create a file named exactly:

Dockerfile

Add:

FROM node:alpine

 

WORKDIR /app

 

COPY . .

 

EXPOSE 3000

 

CMD ["node", "server.js"]

 

Simple Explanation

Command

Meaning

FROM node:alpine

Uses a lightweight Node.js image

WORKDIR /app

Creates/uses /app folder

COPY . .

Copies project files into the container

EXPOSE 3000

Declares port 3000

CMD

Starts the Node.js application

 

 

Step 5: Build the Docker Image

Open the terminal inside your project folder and run:

docker build -t node-docker-app .

Check the image:

docker images

 

Step 6: Run the Docker Container

docker run -d -p 3000:3000 --name node-app node-docker-app

Check the running container:

docker ps

Now open your browser:

http://localhost:3000

You should see:

Hello from Node.js Docker App!

 

 

Step 7: Create a Docker Hub Account

Go to:

Docker Hub

Create an account if you do not already have one.

For example, suppose your Docker Hub username is:

your-dockerhub-username

 

Step 8: Login to Docker Hub

In the terminal, run:

docker login

Enter your Docker Hub username and password when requested.

Step 9: Tag Your Docker Image

Docker Hub needs your username in the image name.

Replace your-dockerhub-username with your actual Docker Hub username:

docker tag node-docker-app your-dockerhub-username/node-docker-app:latest

 

Example

If your username is sofficial333:

docker tag node-docker-app sofficial333/node-docker-app:latest

 

Check it:

docker images

Step 10: Push the Image to Docker Hub 🚀

Run:

docker push your-dockerhub-username/node-docker-app:latest

Example

docker push soffical333/node-docker-app:latest

Docker will upload your image to your Docker Hub repository.

Complete Flow

Create Node.js App

       

Create Dockerfile

       

docker build

       

Docker Image

       

docker run

       

Test on localhost:3000

       

docker login

       

docker tag

       

docker push

       

☁️ Docker Hub

 

Pull the Image on Another Computer

Anyone with access to the repository can download it using:

docker pull your-dockerhub-username/node-docker-app:latest

Then run it:

docker run -d -p 3000:3000 your-dockerhub-username/node-docker-app:latest


This is the basic workflow:

Create App → Build Image → Run Container → Tag Image → Push to Docker Hub → Pull and Run Anywhere.

 

Wednesday, August 19, 2026

Dockerize a Python Application with screen short

How Dockerize a Python Application with screen short

 Project Structure

Create a folder named python-app:

python-app/
├── app.py
└── Dockerfile



Create a python app-

1. app.py

Create a file named app.py:

from http.server import SimpleHTTPRequestHandler, HTTPServer

PORT = 5000


class MyHandler(SimpleHTTPRequestHandler):

def do_GET(self):

self.send_response(200)

self.send_header(
"Content-type",
"text/html"
)

self.end_headers()

self.wfile.write(
b"<h1>Hello World from Docker!</h1>"
)


server = HTTPServer(
("0.0.0.0", PORT),
MyHandler
)

print(f"Server running on port {PORT}")

server.serve_forever()

This creates a simple Python web server on port 5000.



Add Docker file-

2. Dockerfile

Create a file named exactly:

Dockerfile

Add:

FROM python:3.10-slim

WORKDIR /app

COPY app.py .

EXPOSE 5000

CMD ["python", "app.py"]

What each line does

DockerfileMeaning
FROM python:3.10-slimUses a lightweight Python image
WORKDIR /appCreates/uses /app as the working directory
COPY app.py .Copies app.py into the container
EXPOSE 5000Documents that the application uses port 5000
CMDStarts the Python application



3. Build the Docker Image

Open PowerShell inside the python-app folder.

Run:

docker build -t python-web:v1 .

Check the image:

docker images

You should see something similar to:

REPOSITORY TAG IMAGE ID
python-web v1 xxxxxxxxx


4. Run the Container

Run:

docker run -d --name python-web -p 5000:5000 python-web:v1

Check the running container:

docker ps

You should see:

python-web


5. Open in Browser

Open:

http://localhost:5000

You should see:

Hello World from Docker!


6. Check Container Logs

If you want to see what your Python application is doing:

docker logs python-web

You should see:

Server running on port 5000


7. Stop the Container

docker stop python-web

Start it again:

docker start python-web


8. Remove the Container

First stop it:

docker stop python-web

Then:

docker rm python-web


Complete Flow

app.py
Dockerfile
docker build
Python Docker Image
python-web:v1
docker run
Python Container
python-web
Port 5000
http://localhost:5000

The 5 commands you mainly need to remember

Docker Images Push and Pull on Docker Hub

Simple Node.js Application + Deploy to Docker Hub We will create a very simple Node.js web application , create a Docker image, and then u...