Docker

Containers & Commands

Interactive container simulator + 30 command reference. Start with Write Dockerfile.

The Big Picture — Virtualization

Virtual Machines — Old WayHeavy
Your App~50 MB

only your code

Guest OS (full Ubuntu / Windows)5–20 GB

complete kernel + all libs

Hypervisor (VMware / VirtualBox)

emulates hardware for the VM

Host OS (your actual system)

Windows / macOS / Linux

Physical Hardware

CPU · RAM · Disk

⏱ Boot: ~1–2 min  ·  💾 Each VM carries a full OS — slow, bloated, resource-hungry.

Docker Containers — New WayLightweight

web

node:20

:3000

api

python:3

:8000

db

postgres

:5432

Docker Engine~200 MB

lightweight runtime — shares the host kernel, no Guest OS needed

Host OS (shared — not duplicated)

Windows / macOS / Linux — one kernel for all containers

Physical Hardware

CPU · RAM · Disk

⚡ Start: <1 sec  ·  🪶 Containers share the OS kernel — tiny, portable, disposable.

🐳

Image

A read-only blueprint — like a class in OOP. Contains your app + all dependencies, frozen and reproducible.

📦

Container

A running instance of an image — like an object from a class. Isolated process, ephemeral, and disposable.

🏪

Registry

A store for images. Docker Hub is the public one. Pull official images (nginx, postgres, node) or push your own.

Interactive Simulator

LOCAL — Your Machine

Project Files

Dockerfile + source

No Dockerfile yet — click "Write Dockerfile" above

docker build

Local Images

docker images

No images — build or pull one

docker run

Containers

docker ps

No containers — run an image

REGISTRY — Docker Hub

Remote Images

hub.docker.com

No images pushed yet — run docker push

Commands that cross the boundary

docker pushLocal image → Registry
docker pullRegistry → Local image
docker runAuto-pulls if not found locally

0

Running

0

Stopped

0

Images

terminal log

Write a Dockerfile to get started.

Command Reference

docker versionBasics

Show Docker client and server version info.

docker infoBasics

Display system-wide Docker information.

docker helpBasics

List all available Docker commands.

docker pull <image>Images

Download an image from Docker Hub to your machine.

docker build -t <tag> .Images

Build an image from the Dockerfile in the current directory.

docker imagesImages

List all locally available images.

docker rmi <image>Images

Remove a local image by name or ID.

docker image pruneImages

Remove all dangling (untagged) images.

docker run <image>Containers

Create and start a container from an image.

docker run -d <image>Containers

Run a container in detached (background) mode.

docker run -p 3000:3000Containers

Map host port 3000 → container port 3000.

docker run -v ./data:/dataContainers

Mount a host directory as a volume inside the container.

docker psContainers

List all currently running containers.

docker ps -aContainers

List ALL containers including stopped ones.

docker stop <id>Containers

Gracefully stop a running container (SIGTERM).

docker rm <id>Containers

Remove a stopped container permanently.

docker exec -it <id> shContainers

Open an interactive shell inside a running container.

docker logs <id>Containers

View stdout / stderr output of a container.

docker inspect <id>Containers

Return detailed JSON info about a container or image.

docker compose upCompose

Build and start all services in docker-compose.yml.

docker compose up -dCompose

Start Compose services in detached (background) mode.

docker compose downCompose

Stop and remove Compose containers, networks, and volumes.

docker compose logs -fCompose

Stream live logs from all Compose services.

docker compose buildCompose

Rebuild images for all Compose services.

docker network lsNetwork

List all Docker networks.

docker network createNetwork

Create a user-defined bridge network.

docker network inspectNetwork

Display detailed info about a network.

docker loginRegistry

Log in to Docker Hub or a private registry.

docker push <tag>Registry

Upload a tagged local image to a registry.

docker tag <img> <tag>Registry

Create an alias tag for an existing image before pushing.

Course Curriculum

38lessons · 8 chapters · click any lesson for Q&A