Fundamentals 4 min read

Docker Day 1: Grasp Core Concepts in 5 Minutes and Stop Treating Containers as VMs

This article quickly clarifies Docker's three core concepts—image, container, and registry—explains why containers are lightweight processes rather than virtual machines, and provides the essential commands to pull images, run containers, and manage them.

Tech Ocean
Tech Ocean
Tech Ocean
Docker Day 1: Grasp Core Concepts in 5 Minutes and Stop Treating Containers as VMs

1. Clarifying Three Core Concepts

Image – a read‑only blueprint, analogous to a class definition or a recipe.

Container – the instantiated, running object, analogous to an object instance or a cooked dish.

Registry – the storage for images, comparable to a Maven/Go‑mod repository or a marketplace.

One image can spawn multiple independent containers.

2. Containers vs. Virtual Machines

Virtual Machine: Full OS + Hypervisor → Strong isolation, slow start (minutes), high memory use
Container:      Shared host kernel → Weaker isolation (but sufficient), fast start (seconds), low resource use

Key point: A container is a process, not a virtual machine.

Practical example: Starting a local MySQL instance takes about 5 minutes and 2 GB of RAM on a VM, but only 3 seconds and 200 MB on a Docker container, a huge advantage during development.

3. Your First Commands

# Pull an image and run a container
docker run hello-world

# List local images
docker images

# Show running containers
docker ps

# Show all containers (including stopped)
docker ps -a

Running the hello-world image completes the full "pull → create → run" flow.

4. Core Command Set

# Pull an image
docker pull ubuntu:20.04

# Run a container interactively
docker run -it ubuntu:20.04 bash   # -i for interactive, -t allocates a TTY
# Exiting the shell stops the container (whether it is removed depends on options)

# Run a container in the background
docker run -d -p 8080:80 nginx   # -d daemon mode, -p hostPort:containerPort

# Stop / remove a container
docker stop <container_id>
docker rm <container_id>

# Exec into a running container
docker exec -it <container_id> bash

5. Official Docker Concept Diagram

┌─────────────────────────────────────────────┐
│               Docker Host                  │
│  ┌─────────────┐      ┌─────────────────┐ │
│  │   Images    │      │   Containers    │ │
│  │ (static)   │ new  │   (dynamic)     │ │
│  └─────────────┘ ────▶ └─────────────────┘ │
│          ▲                                 │
│          │ pull from                        │
│  ┌───────┴───────┐                         │
│  │   Registry    │ Docker Hub / private repo │
│  └───────────────┘                         │
└─────────────────────────────────────────────┘

6. Day 1 Summary

Containers are processes, not virtual machines.

Image → Container corresponds to Class → Instance.

Core commands to remember: run, ps, images, exec, stop, rm.

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.

Dockercontainercommand-lineVirtualizationimageregistry
Tech Ocean
Written by

Tech Ocean

Focused on AI programming, sharing ready-to-use development efficiency solutions.

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.