DEV Community

Cover image for Docker
Mohanapriyak
Mohanapriyak

Posted on

Docker

🐳 Docker Image Creation and Pushing to Docker Hub

This document explains how to create a Docker image from your project and push it to Docker Hub.


🛠 Step 1: Create a Dockerfile

Place a Dockerfile in the root of your project directory.

FROM python:3.11-slim
RUN pip install pandas scikit-learn matplotlib
COPY . .
CMD ["python","hello_world_ml.py"]

Enter fullscreen mode Exit fullscreen mode

🏗️ Step 2: Build the Docker Image

Use the command below to build the image from the Dockerfile.

docker build -t your-dockerhub-username/image-name:tag .

Enter fullscreen mode Exit fullscreen mode

🚀 Step 3: Push Image to Docker Hub

After building the image, push it to Docker Hub using:

docker push your-dockerhub-username/image-name:tag

Enter fullscreen mode Exit fullscreen mode

Dockerfile Example for Spring Boot

Login to Docker Hub

Pushing Image to Docker Hub

Docker Build Command Example

Docker Push Command Example

Top comments (0)