惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IT之家
IT之家
腾讯CDC
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
K
Kaspersky official blog
V
Visual Studio Blog
博客园 - 聂微东
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
云风的 BLOG
云风的 BLOG
T
Tailwind CSS Blog
C
Check Point Blog
H
Heimdal Security Blog
The GitHub Blog
The GitHub Blog
Google Online Security Blog
Google Online Security Blog
P
Proofpoint News Feed
AI
AI
The Register - Security
The Register - Security
SecWiki News
SecWiki News
Help Net Security
Help Net Security
T
Troy Hunt's Blog
V
V2EX
T
Tenable Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Forbes - Security
Forbes - Security
P
Privacy International News Feed
Microsoft Azure Blog
Microsoft Azure Blog
A
About on SuperTechFans
Recorded Future
Recorded Future
C
Cybersecurity and Infrastructure Security Agency CISA
博客园 - 司徒正美
博客园 - 叶小钗
Y
Y Combinator Blog
人人都是产品经理
人人都是产品经理
S
Security @ Cisco Blogs
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
L
LINUX DO - 最新话题
V2EX - 技术
V2EX - 技术
The Cloudflare Blog
Jina AI
Jina AI
T
The Exploit Database - CXSecurity.com
L
Lohrmann on Cybersecurity
Webroot Blog
Webroot Blog
美团技术团队
N
News and Events Feed by Topic
小众软件
小众软件
Google DeepMind News
Google DeepMind News
G
GRAHAM CLULEY
阮一峰的网络日志
阮一峰的网络日志
B
Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Stop Learning Docker for Dummies. Learn It Like a DevOps Engineer
Akhilesh Mis · 2026-04-26 · via DEV Community

Most Docker tutorials teach you commands.

Not how Docker actually works in real systems.

That's why people can run docker run but freeze when asked to debug a broken container in production.

This post walks you through them in order. Layer caching. Multi-stage builds. Networking. Volumes. ENTRYPOINT vs CMD. docker inspect. The concepts most DevOps engineers fake their way through until they get burned.

Let's go.

The problem Docker solved

The Docker story began with the problems people had 20-30 years ago.

You had bare hardware. You installed an OS on top. You compiled your app and sorted every dependency by hand.

Need to run another application? Buy another server. Spend days setting it up from scratch.

Then virtualization came. Hypervisors let you spin 10–20 VMs on the same hardware.

Better. But the dependency problem stayed.

You still had to install and configure everything on every single VM. Apps worked on one machine. Failed on another.

"Works on my machine" became the most dreaded phrase in software engineering.

Docker killed that phrase.

Why Docker images exist

You install software directly on the machine.

Works fine. Until your app needs Python 3.8 and another app on the same machine needs Python 3.11.

They conflict. One of them breaks.

You start managing dependencies manually. It becomes a full-time job.

So Docker introduced the image.

A Docker image packages everything your app needs. Code. Runtime. Libraries. Environment variables. Config files. All of it, in one artifact.

You build it once. Run it anywhere.

No more "works on my machine." The machine is inside the image.

But an image sitting on disk does nothing. You need to run it.

What is a Docker container

A container is a running process. A live instance of your image.

One image can spin up dozens of containers at the same time. On any machine. On any cloud.

docker run -d -t --name Thor alpine
docker run -d -t busybox

Enter fullscreen mode Exit fullscreen mode

This spins up two containers. Both are minimalist Linux images pulled from Docker Hub.

  • -d runs the container in the background
  • -t attaches a terminal
  • --name gives it a name. Skip it and Docker invents a random one for you

Images sitting idle are useless. Containers made them run.

Inspecting and managing running containers

You have containers running. You don't know which ones.

docker ps        # running containers only
docker ps -a     # all containers, including stopped ones
docker image ls  # see images on your machine

Enter fullscreen mode Exit fullscreen mode

Notice the size. Alpine is around 7MB. A full Ubuntu VM is gigabytes.

That's why you can run 50 containers where you might fit only 5 VMs.

To interact with a running container, exec into it:

# Run a single command inside the container
docker exec -t Thor ls
docker exec -t Thor ps

# Open an interactive shell
docker exec -it Thor sh

Enter fullscreen mode Exit fullscreen mode

-it opens an interactive terminal session. From here you can inspect the filesystem, check processes, read logs, debug your app live. Type exit to come back out.

Container lifecycle commands you'll use every day:

docker stop Thor        # gracefully stop a running container
docker start Thor       # start a stopped container
docker rm Thor          # remove a stopped container
docker rm -f Thor       # force remove a running container

Enter fullscreen mode Exit fullscreen mode

Containers are ephemeral by design. Stop them. Delete them. Spin new ones from the same image. Repeat. The image never changes. Only the containers do.

Building your own Docker image with a Dockerfile

Running other people's images only takes you so far. You need to package your own app.

That's what the Dockerfile does. A blueprint. A plain text file of instructions.

FROM python:3.11
WORKDIR /app
COPY requirements.txt /app
RUN pip install --no-cache-dir -r requirements.txt
COPY app.py /app
EXPOSE 5000
CMD ["python", "app.py"]

Enter fullscreen mode Exit fullscreen mode

What each instruction does:

  • FROM — sets the base image
  • WORKDIR — sets the working directory inside the container
  • COPY — copies files from your machine into the image
  • RUN — executes commands during the build
  • EXPOSE — documents which port your app listens on
  • CMD — the command that runs when the container starts

Build it:

docker build -t flask-image .

Enter fullscreen mode Exit fullscreen mode

The . tells Docker to look for the Dockerfile in the current directory.

But your builds keep taking 3 minutes even when you changed one line of code.

That's a layer caching problem.

Docker layer caching: why your builds are slow

Docker builds images in layers. Every instruction in your Dockerfile is a layer.

When you rebuild, Docker checks each layer top to bottom.

If nothing changed in that layer, Docker reuses the cached version and moves on. If something changed, Docker rebuilds that layer and every layer after it.

This is why order matters in your Dockerfile.

Wrong order — cache breaks every time:

COPY . /app                          # copies everything including app code
RUN pip install -r requirements.txt  # installs dependencies

Enter fullscreen mode Exit fullscreen mode

You change one line in app.py. Docker sees the COPY changed. It invalidates the cache. It reinstalls all your dependencies from scratch. Every single time.

Right order — cache works for you:

COPY requirements.txt /app           # copy only the dependency file first
RUN pip install -r requirements.txt  # cached until requirements change
COPY . /app                          # copy app code last

Enter fullscreen mode Exit fullscreen mode

You change app.py. Docker sees requirements.txt hasn't changed. It uses the cached pip install. Only the final COPY reruns.

Build goes from 3 minutes to 10 seconds.

The rule: copy what changes least, first. Copy what changes most, last.

Cache was there all along. You just had to stop fighting it.

Multi-stage Docker builds: shrink your image size

Your image is 1.2GB. That's a problem.

A large image means slow pulls across environments. More storage cost. More packages installed means more CVEs to patch. A bigger attack surface for anyone who gets inside.

The culprit is usually your base image.

python:3.11 is convenient. It is also built on Debian and ships with compilers, build tools, and packages your running app never needs.

Switch to python:3.11-slim and your image drops a lot. Switch to python:3.11-alpine and it drops further.

But sometimes you need the full build environment to compile dependencies. You just don't need it at runtime.

That's what multi-stage builds solve. Build in one image. Run in another.

# Stage 1: Build
FROM python:3.11 AS builder
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Stage 2: Run
FROM python:3.11-slim
WORKDIR /app
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
COPY app.py .
EXPOSE 5000
CMD ["python", "app.py"]

Enter fullscreen mode Exit fullscreen mode

The first stage uses the full image to install everything.

The second stage starts clean from a slim base. It copies only what it needs from the builder — the installed packages and your app code. Nothing else.

Your final image has no compiler. No build tools. No leftover cache. Just your app and what it needs to run.

Image goes from 1.2GB to under 150MB. Fewer packages. Fewer CVEs. Faster pulls. Smaller attack surface.

Your build environment and your runtime environment are finally separate.

CMD vs ENTRYPOINT in Docker (the real difference)

Most tutorials treat them as the same thing. They are not.

CMD sets the default command. It can be completely overridden.

docker run flask-image python debug.py

Enter fullscreen mode Exit fullscreen mode

That python debug.py replaces your CMD entirely. The container runs your debug script instead.

ENTRYPOINT sets the command that always runs. It cannot be overridden — only appended to.

ENTRYPOINT ["python"]
CMD ["app.py"]

Enter fullscreen mode Exit fullscreen mode

Now python always runs. app.py is just the default argument.

docker run flask-image               # runs: python app.py
docker run flask-image debug.py      # runs: python debug.py
docker run flask-image --version     # runs: python --version

Enter fullscreen mode Exit fullscreen mode

The pattern in production: use ENTRYPOINT for the executable that never changes. Use CMD for the default arguments that might.

Treat them as the same and you hit confusing behavior when passing arguments to containers. Now you know why.

Pushing images to Docker Hub

Docker Hub is the public registry for images. Like GitHub, but for Docker images.

Tag your image first. The tag tells Docker where to push it.

docker tag flask-image yourusername/flask-demo:1.0
docker login
docker push yourusername/flask-demo:1.0

Enter fullscreen mode Exit fullscreen mode

Now anyone, on any machine, anywhere in the world, can pull and run your app:

docker pull yourusername/flask-demo:1.0
docker run -td -p 8080:5000 yourusername/flask-demo:1.0

Enter fullscreen mode Exit fullscreen mode

The image is portable. The environment comes with it. Same behavior everywhere.

But now you hit a new problem. Your container is running. You can't reach it.

Docker networking explained: bridge networks and port forwarding

By default, Docker uses a bridge network.

The container gets its own IP. Your host machine is on a different network. They cannot talk directly.

You try to curl your Nginx container from your laptop. It fails. The container is running. But it is isolated.

Port forwarding solves this:

docker run -t -d -p 5000:80 --name nginx-container nginx:latest

Enter fullscreen mode Exit fullscreen mode

This forwards port 80 inside the container to port 5000 on your host. Now localhost:5000 reaches your container.

But here's the other annoying thing about the default bridge network — containers on it cannot reach each other by name. Only by IP. And IPs change every time a container restarts. You cannot hardcode them.

User-defined Docker networks: how containers talk by name

docker network create my-network

Enter fullscreen mode Exit fullscreen mode

A user-defined network gives you two things the default bridge doesn't:

  1. Isolation — your containers live in their own network, separate from the host
  2. Name resolution — containers can reach each other by name, not by IP
docker run -itd --network my-network --name web-app nginx
docker run -itd --network my-network --name api-app busybox

Enter fullscreen mode Exit fullscreen mode

Now web-app can ping api-app by name. Restart either one with a new IP. Name resolution still works.

In production, your app container talks to your database container by name. This is how.

You can also inspect networks to see who's connected:

docker network ls
docker network inspect my-network

Enter fullscreen mode Exit fullscreen mode

Containers could not find each other reliably. User-defined networks fixed that.

Docker volumes: persistent storage for containers

You stop a container. Start it again. The data inside is gone. Logs. Database writes. Uploaded files. All wiped.

Containers are ephemeral. That is by design. But data cannot be.

Volumes solve this. A volume is storage managed by Docker that lives outside the lifecycle of any container.

docker volume create mydata
docker run -d --mount source=mydata,target=/app nginx:latest

Enter fullscreen mode Exit fullscreen mode

The container writes to /app. Docker stores that data in the volume.

Delete the container. Create a new one. Mount the same volume. The data is still there.

You can also mount the same volume into multiple containers:

docker run -td --mount source=mydata,target=/app/log --name container-1 busybox
docker run -td --mount source=mydata,target=/app/log --name container-2 busybox

Enter fullscreen mode Exit fullscreen mode

Anything container-1 writes to /app/log, container-2 can read. And vice versa.

Your log aggregator reads what your app writes. Your backup container reads what your database writes.

Volume commands you'll use regularly:

docker volume create mydata     # create a volume
docker volume ls                # list volumes
docker volume inspect mydata    # see details including mount path on host
docker volume rm mydata         # delete a volume

Enter fullscreen mode Exit fullscreen mode

Containers were ephemeral. Volumes made data survive them.

Debugging Docker containers in production with docker inspect

This is where most engineers get stuck. They can start containers. They cannot debug them.

docker inspect is the command that changes that.

docker inspect flask-container

Enter fullscreen mode Exit fullscreen mode

It returns everything Docker knows about a running container. In JSON.

The things you actually use it for in production:

# What network is this container on? What IP did it get?
docker inspect flask-container | grep -A 20 "Networks"

# What volumes are mounted? Where do they point on the host?
docker inspect flask-container | grep -A 10 "Mounts"

# What environment variables were actually injected at runtime?
docker inspect flask-container | grep -A 20 "Env"

# Is the health check passing or failing?
docker inspect flask-container | grep -A 10 "Health"

Enter fullscreen mode Exit fullscreen mode

The difference between what you think is running and what is actually running often lives in this output.

Container behaving differently in staging than local? Check the environment variables that were actually injected. Volume not persisting? Check where it is actually mounted. Network connectivity failing? Check which network the container actually joined.

docker inspect shows you reality. Everything else is assumption.

Wrapping up

These are the advanced Docker concepts that separate engineers who run containers from engineers who ship them to production:

  • Layer caching — copy what changes least, first
  • Multi-stage builds — separate build environment from runtime
  • CMD vs ENTRYPOINT — defaults vs always-runs
  • User-defined networks — name resolution between containers
  • Volumes — make data survive containers
  • docker inspect — see what's actually running, not what you think is running

Every one of these exists because something broke in production. Now you know the story behind each.

If you are serious about production-grade DevOps — not tutorial DevOps — I run a 25-week live bootcamp covering AWS, Kubernetes, MLOps, and AIOps. Real projects. Real troubleshooting. The kind of skills that actually show up in interviews.

[25-Week AWS DevOps + MLOps + AIOps Bootcamp →]