
Docker Basics
- 10 installs
- 2 repo stars
- Updated July 29, 2026
- full-statck-skills/docker-skills
Introduces Docker fundamentals: concepts, container vs VM, architecture, installation, and a first-container walkthrough.
About
Serves as the Docker entry point covering concepts, container vs VM, architecture, installation, and running a first container. A developer new to Docker uses it to learn containerization fundamentals.
- Container vs VM comparison
- Docker object model and CLI basics
Docker Basics by the numbers
- 10 all-time installs (skills.sh)
- Ranked #1,007 of 1,435 DevOps & CI/CD skills by installs in the Skillselion catalog
- Data as of Jul 30, 2026 (Skillselion catalog sync)
npx skills add https://github.com/full-statck-skills/docker-skills --skill docker-basicsAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 10 |
|---|---|
| repo stars | ★ 2 |
| Last updated | July 29, 2026 |
| Repository | full-statck-skills/docker-skills ↗ |
What it does
Introduces Docker fundamentals: concepts, container vs VM, architecture, installation, and a first-container walkthrough.
Files
Docker Basics — 概念与基础
Docker 生态的第一入口。从零理解 Docker 概念、架构和基础操作。
When to Use
| ✅ Use When | ❌ Skip When |
|---|---|
| New to Docker, learning from scratch | Already proficient with Docker |
| Need to understand container vs VM | Need specific Dockerfile/CLI commands → docker-build / docker-run |
| Setting up Docker for the first time | Need multi-container orchestration → docker-compose |
| Evaluating whether to adopt Docker | Need security scanning → docker-security |
Core Concepts
| Concept | Definition | Analogy |
|---|---|---|
| Image | Read-only template with app + dependencies | Class definition |
| Container | Runnable instance of an image | Object instance |
| Registry | Repository for storing/sharing images | App Store |
| Docker Engine | Runtime that builds and runs containers | JVM / Python interpreter |
Container vs VM
| Aspect | Container | VM |
|---|---|---|
| Isolation | Process-level (share host kernel) | Hardware-level (full OS) |
| Startup | Seconds | Minutes |
| Size | MB | GB |
| Density | Dozens per host | Few per host |
| Use Case | Microservices, CI/CD, dev environments | Legacy apps, multi-OS, strong isolation |
Docker Architecture
┌─────────────────────────────┐
│ Docker CLI │ ← docker build/run/push...
├─────────────────────────────┤
│ Docker Daemon │ ← dockerd: manages images, containers, networks, volumes
├─────────────────────────────┤
│ containerd │ ← container runtime supervisor
├─────────────────────────────┤
│ runc │ ← OCI runtime (actually runs containers)
└─────────────────────────────┘
│
┌────┴────┐
▼ ▼
Registry Host OS
(Docker (Linux kernel:
Hub) namespaces, cgroups)Quick Start
# Verify installation
docker --version
docker run hello-world
# Pull and run your first container
docker pull nginx:alpine
docker run -d -p 8080:80 --name my-nginx nginx:alpine
# Check it's running
curl localhost:8080
docker ps
docker stop my-nginxDocker Object Model
docker run → Container (running instance of an image)
docker build → Image (built from Dockerfile)
docker pull → Image (downloaded from Registry)
docker push → Image (uploaded to Registry)
docker volume → Volume (persistent data)
docker network → Network (container communication)Installation Path
| OS | Method | Notes |
|---|---|---|
| macOS | Docker Desktop | Includes GUI, CLI, Compose, K8s |
| Windows | Docker Desktop + WSL2 | WSL2 backend recommended |
| Linux | apt/yum install docker-ce | No GUI; add user to docker group |
| CI/Server | Docker Engine only | Minimal footprint |
Key CLI Groups
docker container → create, run, start, stop, rm, ls, inspect, logs, exec
docker image → build, pull, push, tag, ls, rm, prune, inspect
docker volume → create, ls, rm, prune, inspect
docker network → create, ls, rm, inspect, connect, disconnect
docker system → df, prune, info, eventsWorkflow — 推荐学习路径
Step 1: 理解概念: 阅读 Core Concepts(Image/Container/Registry/Engine) Step 2: 安装验证: docker run hello-world 确认安装成功 Step 3: 第一个容器: docker run -d -p 8080:80 nginx:alpine 体验 Step 4: 进阶学习: 掌握 docker build(写 Dockerfile)→ docker run(管理容器) Step 5: 进入生态: 按需探索 docker-dockerfile/docker-build/docker-compose
Gotchas — Common Pitfalls
- Image vs Container confusion:
docker runcreates a NEW container each time. → Recovery: Usedocker start <name>to restart an existing container;docker ps -ato see stopped containers. - Root permission: Linux requires
sudounless user is added todockergroup (security risk: docker group = root access). → Recovery:sudo usermod -aG docker $USER && newgrp dockeror use rootless Docker. - Disk bloat: Old images/volumes/cache accumulate fast. → Recovery:
docker system prune -amonthly; check withdocker system dffirst. - Port conflict:
-p 8080:80means host:8080 → container:80. If host port is taken, change host side. → Recovery:lsof -i :8080to find process occupying the port, then use a different port. - Data loss: Without volumes, container data is ephemeral. → Recovery: Always use
-v volume_name:/datafor stateful data; never rely on container filesystem.
Boundary — 能力边界(适用与不适用场景)
| 分类 | 场景 | 说明 |
|---|---|---|
| ✅ 能做 | Docker 概念教学(Image/Container/Registry/Engine) | 从零解释核心概念 |
| ✅ 能做 | 安装指导(macOS/Linux/Windows) | 提供各平台安装步骤 |
| ✅ 能做 | 第一个容器实操 | docker run hello-world + nginx 示例 |
| ⚠️ 需条件 | 深入理解容器原理 | 建议结合 Linux namespace/cgroups 文档 |
| ⚠️ 需条件 | Docker Compose 多容器 | 基础概念后进入 docker-compose 技能 |
| ❌ 超范围 | 编写 Dockerfile | 使用 docker-dockerfile |
| ❌ 超范围 | 构建/推送镜像 | 使用 docker-build |
| ❌ 超范围 | 生产部署/Swarm/K8s | 使用 docker-production |
When NOT to Use This Skill
| ❌ Skip | ✅ Use Instead |
|---|---|
| Need to write Dockerfile | docker-build |
| Need container management | docker-run |
| Need multi-container apps | docker-compose |
| Already know Docker basics | Jump to specific skill |
Security & Stability
- All examples are educational. Use official images and verified publishers in production.
- Docker group membership on Linux is equivalent to root access.
- No executable scripts bundled. This skill teaches concepts and basic operations.
📚 官方文档参考
| 文档 | 地址 |
|---|---|
| Docker 概述 | https://docs.docker.com/get-started/docker-overview/ |
| Docker 概念 | https://docs.docker.com/get-started/docker-concepts/the-basics/what-is-a-container/ |
| 安装 Docker | https://docs.docker.com/get-started/get-docker/ |
| Docker 引擎 | https://docs.docker.com/engine/ |
| Docker 入门 workshop | https://docs.docker.com/get-started/workshop/ |
| Docker CLI 参考 | https://docs.docker.com/reference/cli/docker/ |
🧭 Docker Skills Journey
📍 You are here: `docker-basics` — Step 1: Docker 概念与基础
basics → build → run → networking/storage → compose → security/cicd → production/troubleshooting → ai-ml→ Next: docker-build — Write Dockerfiles and build optimized images
FAQ
Q1: 如何快速上手此技能? A: 参考上方的快速开始章节,按步骤操作即可。
Q2: 遇到版本不兼容问题怎么办? A: 检查依赖版本,使用 lock 文件锁定,参考常见陷阱章节。
Q3: 如何在生产环境使用? A: 参考最佳实践章节,确保配置正确,做好监控和日志。
Q4: 性能如何优化? A: 参考性能优化相关文档,使用缓存、索引等手段。
Q5: 如何贡献或反馈问题? A: 在 GitHub 仓库提交 Issue 或 Pull Request。
Q6: 是否支持中文? A: 支持中文文档和中文注释,详见国内适配章节。
Your first Docker container
# 1. Verify Docker is installed
docker --version
# 2. Run hello-world (one-off container)
docker run hello-world
# 3. Run an interactive Ubuntu container
docker run -it ubuntu:22.04 bash
# Inside: whoami / cat /etc/os-release / exit
# 4. Run a background web server
docker run -d --name my-nginx -p 8080:80 nginx:alpine
curl localhost:8080
docker stop my-nginx
docker rm my-nginxContainer lifecycle demo
# Create (doesn't start)
docker create --name demo nginx:alpine
# Start
docker start demo
# Check status
docker ps
docker ps -a
# Stop
docker stop demo
# Start again (no data loss with volumes)
docker start demo
# Remove
docker stop demo && docker rm demo
# One-liner: create, start, auto-remove on stop
docker run --rm -d --name demo nginx:alpineDocker Architecture
Docker Client (CLI)
↓ REST API
Docker Daemon (dockerd)
├── Image Management (build/pull/push)
├── Container Runtime (via containerd)
├── Network Management (bridge/overlay/host)
└── Volume Management (local/NFS/cloud)
containerd (container supervisor)
↓
runc (OCI runtime — creates containers)
↓
Linux Kernel (namespaces + cgroups)Key Linux features Docker uses
| Feature | Purpose |
|---|---|
| Namespaces | Process isolation (PID, NET, MNT, UTS, IPC, USER) |
| Cgroups | Resource limits (CPU, memory, I/O) |
| UnionFS (overlay2) | Layered filesystem for images |
Container vs VM
Virtual Machine: Container:
┌──────────┐ ┌──────────┐ ┌───┐ ┌───┐ ┌───┐
│ App A │ │ App B │ │ A │ │ B │ │ C │
├──────────┤ ├──────────┤ └─┬─┘ └─┬─┘ └─┬─┘
│ Bins/Libs│ │ Bins/Libs│ ┌─┴──────┴──────┴─┐
├──────────┤ ├──────────┤ │ Docker Engine │
│Guest OS │ │Guest OS │ ├─────────────────┤
├──────────┤ ├──────────┤ │ Host OS │
│ Hypervisor (Type 2) │ ├─────────────────┤
├───────────────────────┤ │ Infrastructure │
│ Host OS │ └─────────────────┘
├───────────────────────┤
│ Infrastructure │
└───────────────────────┘
Size: GBs per VM Size: MBs per container
Start: ~1 min Start: ~1 sec
Density: 5-10/host Density: 50-100/host
Isolation: Strong (HW) Isolation: Process-level (kernel shared)Docker 安装指南
macOS
| 方案 | 特点 | 推荐度 |
|---|---|---|
| Docker Desktop | GUI + 自动更新 + K8s 集成 | ⭐⭐⭐ |
| OrbStack | 轻量、快速、原生文件共享 | ⭐⭐⭐⭐ |
| Colima | 免费开源、CLI 驱动 | ⭐⭐⭐ |
Docker Desktop
brew install --cask docker
# 启动 Docker Desktop.app,根据向导完成OrbStack
brew install orbstack
# 启动 OrbStack.appColima
brew install colima docker docker-compose
colima start --cpu 4 --memory 8 --disk 60
docker ps # 验证Linux
# Ubuntu/Debian
curl -fsSL https://get.docker.com | sudo sh
sudo usermod -aG docker $USER
newgrp docker
# CentOS/RHEL/Fedora
sudo dnf install docker-ce docker-ce-cli containerd.io
sudo systemctl enable --now dockerWindows
- WSL 2 + Docker Desktop(推荐)
winget install Docker.DockerDesktop
验证安装
docker --version
docker compose version
docker run --rm hello-world卸载
# macOS(Docker Desktop)
brew uninstall --cask docker
# Linux
sudo apt purge docker-ce docker-ce-cli containerd.io
sudo rm -rf /var/lib/docker /var/lib/containerd