Hackforge Academy

Category: java

What is Docker?

Published on 13 Aug 2026

Explanation

Docker is a containerization platform that packages an application together with its runtime dependencies. Containers provide consistent environments across development, testing, and production systems.

Code:

Application
+ Java
+ Dependencies
+ Configuration
        ↓
     Docker Image
        ↓
     Container

Explanation

A Docker image is a read-only template containing the application and its dependencies. A container is a running instance created from that image.

Code:

docker build -t student-api .

docker run -p 8080:8080 student-api

Explanation

A Dockerfile contains instructions for building a Docker image. For a Spring Boot application, it can copy the generated JAR and define Java as the runtime environment.

Code:

FROM eclipse-temurin:21-jre

WORKDIR /app

COPY target/student-api.jar app.jar

EXPOSE 8080

ENTRYPOINT ["java", "-jar", "app.jar"]

Explanation

After creating the Dockerfile, use docker build to create an image. The image can then be executed as a container on any machine with Docker installed.

Code:

mvn clean package

docker build -t student-api:1.0 .

docker images

Explanation

Docker containers can expose application ports to the host machine. Port mapping allows clients to access the Spring Boot REST API running inside the container.

Code:

docker run -d \
  --name student-api \
  -p 8080:8080 \
  student-api:1.0

πŸš€ Learn Spring Boot with real-world projects

πŸ’‘ Build REST APIs step by step

🧠 Improve backend development skills

🎯 Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

🐍

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
βš›οΈ

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community
β˜•

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community