M4RKYU.SYSEdition 2027
Skip to content
LOCZH/安大略 · 加拿大/▸logs · introduction to docker containers with commands amf待机OK/--:--:--EST
M4M4RK_YUportfolio
  • 创作创作
    创作Overview
    • 作品精选案例与项目记录
    • 游戏可玩原型与游戏开发日志
  • 影像影像
    影像Overview
    • 照片影像合集与视觉实验
    • 商店印刷品、海报和限量物件
  • 写作写作
    写作Overview
    • 博客长篇开发日志与现场笔记
    • 笔记短观察、链接与代码片段
  • 资源资源
    资源Overview
    • 工具38 款浏览器内开发工具
    • 链接每日使用的开发与设计书签
  • 关于关于
  • 联系联系
EN

同步 · dev.to / @markyu

Docker Containers: The Commands That Prove Isolation

A practical Docker container guide focused on the commands that show image layers, process isolation, networking, volumes, and debugging.

发布日期
May 3 '24
·
阅读时长
2 min read
·
点赞
10
dockerdevopscontainersbeginners
在 dev.to 查看

本页目录

  • Run a Container
  • What Is Actually Running?
  • Build a Small Image
  • Check Logs
  • Volumes: Data That Survives the Container
  • Networking: Host Port vs Container Port
  • Containers vs Virtual Machines
  • My Docker Debug Checklist
  • Final Thought

The first time Docker made sense to me was not from a definition.

It was from running a container, checking the process list, deleting the container, and realizing my host system stayed clean.

Containers are not tiny virtual machines. They are isolated processes with packaged files, network settings, and resource boundaries.

Let’s prove that with commands.

Run a Container

docker run --name web-demo -d -p 8080:80 nginx

Open:

http://localhost:8080

Check it:

docker ps

Stop and remove it:

docker stop web-demo
docker rm web-demo

That is the basic lifecycle.

What Is Actually Running?

docker run --name shell-demo -it ubuntu bash

Inside the container:

ps aux
cat /etc/os-release

In another terminal on the host:

docker exec shell-demo ps aux

You are not booting a full separate machine. You are running a process in an isolated environment.

Visual map:

Host kernel
   |
   +-- container process: nginx
   +-- container process: ubuntu bash
   +-- normal host processes

That kernel sharing is why containers start fast.

Build a Small Image

Create Dockerfile:

FROM node:22-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
CMD ["node", "server.js"]

Build it:

docker build -t my-api:1.0 .

Run it:

docker run --rm -p 3000:3000 my-api:1.0

The image is the template. The container is the running instance.

Check Logs

docker logs web-demo
docker logs -f web-demo

When a container exits immediately, logs are usually the first place I look.

Then inspect:

docker inspect web-demo

inspect is noisy, but useful for environment variables, network settings, mounts, and container state.

Volumes: Data That Survives the Container

Containers are disposable. Data sometimes is not.

docker volume create mysql-data

docker run --name mysql-demo \
  -e MYSQL_ROOT_PASSWORD=secret \
  -v mysql-data:/var/lib/mysql \
  -d mysql:8

Remove the container:

docker rm -f mysql-demo

The named volume can still exist:

docker volume ls

That separation matters in production.

Networking: Host Port vs Container Port

This command:

docker run -p 8080:80 nginx

means:

host port 8080 ---> container port 80

The left side is your machine. The right side is inside the container.

I still see beginners flip those numbers and then wonder why the app is unreachable.

Containers vs Virtual Machines

TopicContainerVM
Startupsecondsslower
Kernelshares host kernelown guest OS
Isolationprocess-levelmachine-level
Image sizeusually smallerusually larger
Best fitapp packagingstrong OS isolation

I would not say containers are "better" than VMs. They solve different problems.

My Docker Debug Checklist

docker ps -a
docker logs <container>
docker inspect <container>
docker exec -it <container> sh
docker images
docker volume ls
docker network ls

If you know those commands, you can debug most beginner Docker problems.

Final Thought

Docker becomes less mysterious when you stop treating it as magic packaging and start inspecting what it actually runs.

What Docker command helped containers finally click for you?

相关阅读

Network Address Calculation: The Subnet Math That Matters

A practical subnetting guide showing how to calculate a network address from an IP address and mask using binary math and simple examples.

networking

Kubernetes Is Useful, but Only After These Basics Hurt

A practical Kubernetes guide for developers: pods, deployments, services, config, scaling, and when not to introduce Kubernetes too early.

kubernetes

Frontend Linear Data Structures Deep Dive: Arrays, Stacks, Queues, and Linked Lists

The Big Picture Before diving into stacks, queues, and linked lists, it helps to know...

computerscience

原文发布

本文首发于 dev.to,评论与点赞保留在原站。

在 dev.to 继续阅读
上一篇React Loading Screens Are a State Machine ProblemA practical React loading screen guide using hooks, request states, error states, CSS animation, and why spinners alone are not enough.
返回全部文章
下一篇Sustainable Cloud Design Starts With Boring Cost SignalsA practical cloud sustainability guide for developers: right-sizing, autoscaling, regions, storage lifecycle, carbon-aware thinking, and cost visibility.
返回档案
M4RKYUM4RKYUM4RKYUM4RKYUM4RKYUM4RKYUM4RKYUM4RKYU
始于 2024
ZhenXiao Mark YuZhenXiao Mark Yu
联系

看到什么有意思的?和我聊聊。

这是一个作品集,不是服务 · 但每一条留言我都会看 — 如果哪里让你有所触动,或者只想打个招呼,欢迎写信过来。

开启对话
频道开放

随时打个招呼 · 2026

--:--:--EST加拿大 安大略
  • 邮件
  • GitHub
  • dev.to
  • 领英
  • 推特 / X
  • Instagram
  • Facebook
  • YouTube
  • CodePen
  • Spotify
  • Snapchat

订阅

偶尔收到一封简讯

来自 m4rkyu.com 的笔记与日志——简短、标注日期、没有杂音。随时可退订。

作品

线上发布、游戏作品与视觉档案。

  • 项目
  • 游戏
  • 档案
  • 日志

资源

每日好用的工具与个人收藏的链接库。

  • 搜索
  • 最新
  • 工具
  • 链接
  • 笔记
  • 主题
  • 商店
RSSJSON Feed

工作室

背景、联系方式以及合作渠道。

  • 关于
  • 联系
  • 更新日志
  • 技术说明
  • 简历筹备中

社交

在常去的平台上找到我。

  • GitHub
  • dev.to
  • 领英
  • 推特 / X
  • Instagram
  • Facebook
  • YouTube
  • CodePen
  • Spotify
  • Snapchat
  • 邮件
© 2026 ZhenXiao Mark Yumarkyu0615@gmail.com
  • 邮件
  • GitHub
  • dev.to
  • 领英
  • 推特 / X
  • Instagram
  • Facebook
  • YouTube
  • CodePen
  • Spotify
  • Snapchat
隐私条款由 Next.js 16 · React 19 · Tailwind 4 构建