← Back to list

Docker Demystified: A Beginner-Friendly Guide from Architecture to Multi-Container Apps

Introduction

Anupamaem · 2026-06-10 15:41 · 0 claps · 4.0 min read
#docker #docker-compose #dockerfiles #docker-basic #docker-network
Open on Medium ↗
Wiki topics: ☁️ · DevOps & Cloud 🏛️ · Architecture

Docker Demystified: A Beginner-Friendly Guide from Architecture to Multi-Container Apps

Introduction

Ever run into the infamous “Well, it works on my machine” problem? We have all been there. Developers frequently waste hours debugging code that runs perfectly locally but breaks the moment it hits a testing server or production environment.

Enter Docker, an open-source platform designed to eliminate this exact friction. Docker automates the deployment of applications inside lightweight, portable containers. By packaging your software alongside all its mandatory dependencies, libraries, and configurations, Docker guarantees your application behaves identically across any system.

While Docker didn’t technically invent containerization, it undeniably popularized it by making it fast, efficient, and highly accessible.

The Mental Model: What is Docker, Exactly?

To understand Docker, it helps to separate the concepts using everyday analogies.

The Dockerfile (The Recipe)

A simple text file filled with step-by-step instructions on how to assemble your application environment.

The Docker Image (The Cake Mix)

A frozen, read-only template built from your Dockerfile. It contains your code, runtime, and tools packaged and ready.

The Container (The Baked Cake)

The living, breathing, executable instance of your image running on a machine.

Docker Containers vs. Virtual Machines

Unlike bulky Virtual Machines (VMs) that bundle a whole guest operating system, Docker containers share the host operating system kernel. This architectural shortcut makes containers incredibly lightweight, fast to boot, and highly resource-efficient.

Inside the Docker Architecture

Docker uses a client-server architecture split into a few core internal components.

Docker Client (CLI)

Your command center. This is where you type commands like docker build or docker run. It relays your instructions via a REST API to the background system.

Docker Host (Engine & Daemon)

The heavy lifter. It runs a background process called the Daemon (dockerd), which acts as the brain responsible for managing, building, and running your containers and images.

Docker Registry

A central repository where images are stored and shared. Docker Hub is the largest public registry in the world, similar to GitHub but for Docker images.

The Build, Ship, Run Workflow

The fundamental lifecycle of a Docker application boils down to three sequential steps.

  1. BUILD (From Code to Blueprint)

You draft a Dockerfile defining your environment requirements, such as installing Linux, installing Java, and copying application code. Running docker build prompts the Docker Daemon to compile this text file into an immutable, read-only image.

  1. SHIP (To the Warehouse)

You execute docker push to upload your local image safely to a registry like Docker Hub, allowing your team or production servers to access it from anywhere.

  1. RUN (From Blueprint to Reality)

On the target deployment server, you trigger docker pull to fetch the image from the registry. Running docker run commands the engine to place a thin writable layer on top of that read-only image, executing it instantly as an active container.

Breaking Down a Real Dockerfile

Let’s dissect a common Dockerfile configuration to understand the commands driving automation.

FROM eclipse-temurin:21
WORKDIR /app
COPY target/example.jar /app/example.jar
COPY target/lib/ /app/lib/
EXPOSE 8080
CMD ["java", "-jar", "example.jar"]

Essential Dockerfile Commands to Know

FROM

Sets the baseline image your environment builds upon.

WORKDIR

Sets the working directory path inside the container context.

COPY

Transports files or directories from your local filesystem into the container filesystem.

RUN

Executes terminal commands during the image build phase, such as:

RUN apt-get update

CMD vs ENTRYPOINT

CMD defines the default program that starts when your container launches, whereas ENTRYPOINT ensures a specific executable always runs on startup.

ENV and ARG

ENV injects runtime environment variables, while ARG sets temporary variables used strictly during the image build process.

Data Management: Volumes vs. Bind Mounts

Because containers are inherently ephemeral, any data created inside them disappears the moment the container is deleted. Docker solves this data persistence problem in two ways.

Docker Volumes

Management: Entirely managed by Docker.

Storage Location: /var/lib/docker/volumes/ on Linux.

Best Used For: Production environments, databases, and secure long-term storage.

Lifecycle: Outlives the container and requires explicit deletion.

Bind Mounts

Management: Managed by the user through host machine paths.

Storage Location: Anywhere you choose on your host machine.

Best Used For: Development environments with real-time code synchronization.

Lifecycle: Directly tied to the host folder’s state.

Quick Syntax Tip

You can set up data mapping using the older -v flag or the modern --mount syntax.

docker run -d --mount type=bind,source="$(pwd)"/target,target=/app nginx:latest

Networking and Port Mapping

Containers operate inside their own isolated network stack. If a web server inside a container listens on port 3000, it remains completely hidden from the host machine or external internet traffic by default.

To make your application accessible externally, you must map a host port to a container port using the -p flag.

docker run -p [HOST_PORT]:[CONTAINER_PORT] [IMAGE_NAME]

Example:

docker run -p 3000:3000 node-app

Once configured, outside traffic targeting http://localhost:3000 is transparently forwarded into your container.

Connecting Container to Container

Docker offers a built-in networking feature so containers can securely communicate with each other by name instead of dynamic IP addresses.

docker network create my-custom-net
docker run --name database -d --network my-custom-net mongo

Any application container placed on my-custom-net can now find the database container simply by using the hostname:

mongodb://database

Moving to Multi-Container Apps with Docker Compose

Running one container manually via CLI commands is easy enough, but managing a modern application stack consisting of a frontend, API service, vector database, and cache backend quickly becomes difficult.

Docker Compose allows you to orchestrate multi-container application stacks using a single configuration file named docker-compose.yml.

version: '3.8'
services:
  api:
    build: .
    ports:
      - "8000:8000"
    depends_on:
      - qdrant
  qdrant:
    image: qdrant/qdrant
    volumes:
      - qdrant_data:/qdrant/storage
volumes:
  qdrant_data:

Essential Commands Cheat Sheet

Download an image

Docker: docker pull <image>

Docker Compose: Handled automatically

Start services

Docker: docker run -d <image>

Docker Compose: docker compose up

Stop services

Docker: docker stop <container-id>

Docker Compose: docker compose down

View logs

Docker: docker logs <container-id>

Docker Compose: docker compose logs <service>

Check running processes

Docker: docker ps -a

Docker Compose: docker compose ps

Execute commands inside a container

Docker: docker exec -it <id> bash

Docker Compose: docker compose run <service> bash

Conclusion

Docker wraps your applications in an indestructible layer of consistency, portability, and isolated scale. Mastering how images, containers, volumes, and networking interconnect is the first step toward building modern, cloud-native deployments that work flawlessly on every machine.


메타데이터
post_id
5008a5a045ce
slug
docker-demystified-a-beginner-friendly-guide-from-architecture-to-multi-container-apps-5008a5a045ce
url
https://medium.com/@anupamaem923/docker-demystified-a-beginner-friendly-guide-from-architecture-to-multi-container-apps-5008a5a045ce
canonical_url
https://medium.com/@anupamaem923/docker-demystified-a-beginner-friendly-guide-from-architecture-to-multi-container-apps-5008a5a045ce
author_url
https://medium.com/@anupamaem923
status
ok
fetched_at
2026-06-15 20:49:13