SuperAPI AI Directory

docker-basics

Deployment & operations

View repository

Updated 10-15 21:48

About this skill

Docker Basics — Concepts and Fundamentals

The first entry point to the Docker ecosystem. Understand Docker concepts, architecture, and basic operations from scratch.

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-nginx

Docker 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, events

Workflow — Recommended Learning Path

Step 1: Understand Concepts: Read Core Concepts (Image/Container/Registry/Engine) Step 2: Installation Verification: docker run hello-world Confirm successful installation Step 3: First Container: docker run -d -p 8080:80 nginx:alpine Experience Step 4: Advanced Learning: Master docker build (write a Dockerfile) → docker run (manage containers) Step 5: Enter the Ecosystem: Explore as needed docker-dockerfile/docker-build/docker-compose

Gotchas — Common Pitfalls

  • Image vs Container confusion: docker run creates a NEW container each time. → Recovery: Use docker start <name> to restart an existing container; docker ps -a to see stopped containers.
  • Root permission: Linux requires sudo unless user is added to docker group (security risk: docker group = root access). → Recovery: sudo usermod -aG docker $USER && newgrp docker or use rootless Docker.
  • Disk bloat: Old images/volumes/cache accumulate fast. → Recovery: docker system prune -a monthly; check with docker system df first.
  • Port conflict: -p 8080:80 means host:8080 → container:80. If host port is taken, change host side. → Recovery: lsof -i :8080 to find process occupying the port, then use a different port.
  • Data loss: Without volumes, container data is ephemeral. → Recovery: Always use -v volume_name:/data for stateful data; never rely on container filesystem.

Boundary — Capability Boundaries (applicable and non-applicable scenarios)

Category Scenario Description
✅ Can do Docker concept teaching (Image/Container/Registry/Engine) Explain core concepts from scratch
✅ Can do Installation guidance (macOS/Linux/Windows) Provide installation steps for each platform
✅ Can do First container hands-on docker run hello-world + nginx example
⚠️ Conditional In-depth understanding of container principles Recommended to combine with Linux namespace/cgroups documentation
⚠️ Conditional Docker Compose multi-container After basic concepts, proceed to docker-compose skills
❌ Out of scope Writing Dockerfiles Use docker-dockerfile
❌ Out of scope Building/pushing images Use docker-build
❌ Out of scope Production deployment/Swarm/K8s Use 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.

📚 Official Documentation References

Documentation URL
Docker Overview https://docs.docker.com/get-started/docker-overview/
Docker Concepts https://docs.docker.com/get-started/docker-concepts/the-basics/what-is-a-container/
Install Docker https://docs.docker.com/get-started/get-docker/
Docker Engine https://docs.docker.com/engine/
Docker Getting Started workshop https://docs.docker.com/get-started/workshop/
Docker CLI Reference https://docs.docker.com/reference/cli/docker/

🧭 Docker Skills Journey

📍 You are here: docker-basics — Step 1: Docker Concepts and Fundamentals

basics → build → run → networking/storage → compose → security/cicd → production/troubleshooting → ai-ml

→ Next: docker-build — Write Dockerfiles and build optimized images

FAQ

Q1: How can I get started with this skill quickly? A: Refer to the Quick Start section above and follow the steps.

Q2: What should I do if I encounter version incompatibility issues? A: Check dependency versions, use a lock file to pin them, and refer to the Common Pitfalls section.

Q3: How do I use it in a production environment? A: Refer to the Best Practices section, ensure the configuration is correct, and set up monitoring and logging.

Q4: How can performance be optimized? A: Refer to the performance optimization documentation and use techniques such as caching and indexing.

Q5: How can I contribute or provide feedback? A: Submit an Issue or Pull Request in the GitHub repository.

Q6: Is Chinese supported? A: Chinese documentation and Chinese comments are supported; see the domestic adaptation section for details.