1. Let’s talk about the conclusion first (how to learn with the least pain)
- The order must be: Docker → Kubernetes (K8s)
- Docker is "how to put programs into boxes"
- K8s is "how to manage a bunch of boxes"
Without Docker, K8s is basically incomprehensible.
2. Docker Tutorial (Getting Started → Practical Combat)
1️⃣ What is Docker (one sentence version)
- Package the program + running environment into an Image
- It runs as Container
- No longer afraid of "it can run on my computer"
2️⃣ Docker must learn core concepts (interview & practical)
| Concept | One sentence |
|---|---|
| Image | The "installation package" of the program |
| Container | Running Image |
| Dockerfile | How to build Image |
| Volume | Data persistence |
| Network | Communication between containers |
| Registry | Mirror Warehouse (Docker Hub) |
3️⃣ Getting started with Docker (must type by yourself)
bash
# 1. 拉镜像
docker pull nginx
# 2. 运行容器
docker run -d -p 8080:80 nginx
# 3. 看运行状态
docker ps
# 4. 停止容器
docker stop <container_id>Browser access 👉 http://localhost:8080
4️⃣ Dockerfile (Key Points‼️)
Minimal usable example (Python)
dockerfile
FROM python:3.10-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "app.py"]Build & Run:
bash
docker build -t myapp .
docker run -p 5000:5000 myapp👉 This step is a watershed for Docker
5️⃣ Docker advanced (learn this and you can already work)
Multiple containers:
docker-composeData persistence:
volume / bind mountImage optimization: multi-stage build
Common pitfalls:
- The port is not exposed
- The container exits as soon as it starts
- Image is too large (>1GB)
3. Kubernetes (K8s) Tutorial (Key Points🔥)
1️⃣ What is K8s used for?
In one sentence:
Automatic deployment, expansion and contraction, restart, and load balancing of Docker containers
When you have:
- multiple servers
- multiple services
- High availability requirements 👉 K8s only makes sense
2️⃣ K8s core concepts (must memorize)
| Concept | Human explanation |
|---|---|
| Pod | Minimum deployment unit (1 ~ multiple containers) |
| Node | A machine |
| Cluster | A bunch of Node |
| Deployment | Manage Pods (replicas, upgrades) |
| Service | Give Pod a stable entrance |
| ConfigMap | Configuration |
| Secret | Password |
| Ingress | HTTP entry |
3️⃣ Local learning environment (recommended)
✅ First choice for newbies:
minikubeorkind
bash
brew install minikube
minikube start4️⃣ The first K8s application (very important)
deployment.yaml
yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas: 2
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: nginx
ports:
- containerPort: 80bash
kubectl apply -f deployment.yaml
kubectl get pods5️⃣ Service (allowing external access)
yaml
apiVersion: v1
kind: Service
metadata:
name: myapp-service
spec:
type: NodePort
selector:
app: myapp
ports:
- port: 80
targetPort: 80
nodePort: 300076️⃣ K8s capabilities you really need to master
- Why does the Pod hang?(
kubectl describe pod) - What do you think of the log?(
kubectl logs) - rolling update
- HPA automatic expansion
- Health check (liveness/readiness)
- Configuration and key management
4. Docker + K8s learning route (follow it)
🟢 Phase 1 (3–5 days)
- Docker basic commands
- Dockerfile
- Run your own web service
🟡Phase 2 (5–7 days)
- docker-compose
- K8s basic concepts
- Deployment + Service
🔵 The third stage (advanced)
- Helm
- CI/CD(GitHub Actions)
- K8s on the cloud (EKS / GKE / ACK)
5. Highly recommended learning resources (high quality)
📘 Official (Must See)
- Docker Docs
- Kubernetes official documentation (available in Chinese)
🎥 Video (suitable for Chinese)
- Bilibili: Silicon Valley Docker/K8s
- Dark Horse Programmer Kubernetes
🧪 Practical projects
- Spring Boot / FastAPI + Docker + K8s
- Microservice deployment