Cloud Native 3 min read

Master Docker Deployment: From Dockerfile to Running Containers

This article walks through Docker’s essential role in modern cloud-native architectures, explaining why containerization solves environment inconsistencies, and provides a step‑by‑step guide—including writing a Dockerfile, building images, running containers, and accessing services—for deploying Spring Boot microservices efficiently.

Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Master Docker Deployment: From Dockerfile to Running Containers

Docker is a containerization technology that packages applications and their dependencies into portable containers, greatly simplifying deployment.

Traditional deployment often suffers from environment differences (OS version, library mismatches), causing “works on dev machine, fails in production”. Docker solves this by bundling the runtime, libraries, and configuration into an image, ensuring consistency across development, testing, and production environments.

Docker containers share the host OS kernel, using fewer resources and starting in seconds compared to virtual machines.

Docker deployment illustration
Docker deployment illustration

Docker Deployment Process

The basic workflow: write a Dockerfile → build an image → run a container → access the service.

1. Write Dockerfile

FROM openjdk:17-slim
WORKDIR /app
COPY target/user-service.jar app.jar
EXPOSE 8081
ENTRYPOINT ["java","-jar","app.jar"]

2. Build Image

docker build -t user-service:1.0 .

You can build separate images for multiple microservices, e.g.:

docker build -t order-service:1.0 ./order
docker build -t product-service:1.0 ./product

3. Run Container

docker run -d -p 8081:8081 --name user user-service:1.0

Run additional containers for other services:

docker run -d -p 8082:8082 --name order order-service:1.0
docker run -d -p 8083:8083 --name product product-service:1.0

4. Access Service

http://localhost:8081/api/users
http://localhost:8082/api/orders

This process enables fast, standardized deployment of microservices, ensuring environment consistency and efficient management.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DockerMicroservicesDevOpscontainerizationSpring Boot
Mike Chen's Internet Architecture
Written by

Mike Chen's Internet Architecture

Over ten years of BAT architecture experience, shared generously!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.