1) Create the account on https://hub.docker.com/ so you can trace your docker container/images.
2) You will get the username which we required for running your container you have to configured it over the docker with username and password.
3) You also need the Dockerfile to run the containers so make sure you are in the same folder where this dockerfile is present .
4) Follow the below command step by step
🟢 Step 1: Write a Dockerfile
🟢 Step 2: Build Docker Image
docker build -t <your-dockerhub-username>/<image-name>:<tag> .
# Example:
docker build -t iamnk007p/python-sample-app-demo:v1 .
🟢 Step 3: Verify Image is Built
docker images
🟢 Step 4: Run Container from Image
docker run -d -p 5000:5000 --name my-python-app iamnk007/python-sample-app-demo:v1
# -d = detached mode
# -p = port mapping (host:container)
# --name = custom container name
or you can run below command as well just make sure you are mentioning port in dockerfile
docker run -it iamnk007/python-sample-app-demo
🟢 Step 5: Check Running Containers
docker ps
🟢 Step 6: Access Application in Browser
Open: http://localhost:5000
(Depends on your app's port)
✅ Push Docker Image to Docker Hub
🟢 Step 8: Login to Docker Hub
docker login
🟢 Step 9: Push Image to Docker Hub ( make sure you add tag (v1))
docker push iamnk00/python-sample-app-demo:v1
✅ Stopping & Cleaning Up
docker stop my-python-app
🟢 Remove Container
docker rm my-python-app
🟢 Remove Image (Optional)
docker rmi iamnk007/python-sample-app-demo:v1
summary (Quick Recap Commands):
docker build -t <username>/<image>:<tag> .
docker run -d -p 5000:5000 --name <container-name> <username>/<image>:<tag>
docker ps
docker login
docker push <username>/<image>:<tag>
docker stop <container-name>
docker rm <container-name>
docker rmi <username>/<image>:<tag>