M4RKYU.SYSEdition 2027
Skip to content
LOCEN/Ontario · CA/▸logs · introduction to docker containers with commands amfStandbyOK/--:--:--EST
M4M4RK_YUportfolio
  • BuildBuild
    BuildOverview
    • WorkSelected case studies and write-ups
    • GamesPlayable prototypes and game-dev logs
  • GalleryGallery
    GalleryOverview
    • PhotosPhoto collections and visual experiments
    • ShopPrints, posters, and one-off objects
  • WritingWriting
    WritingOverview
    • BlogLong-form devlogs and field notes
    • NotesShort observations, links, snippets
  • ResourcesResources
    ResourcesOverview
    • Tools38 in-browser developer utilities
    • LinksDaily-use dev and design bookmarks
  • AboutAbout
  • ContactContact
中文

syndicated · 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.

Published
May 3 '24
·
Reading time
2 min read
·
Reactions
10
dockerdevopscontainersbeginners
View on dev.to

On this page

  • 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?

Related reading

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

originally published

This post first ran on dev.to. Comments and reactions live there.

Continue on dev.to
PreviousReact 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.
Back to all posts
NextSustainable 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.
Back to archive
M4RKYUM4RKYUM4RKYUM4RKYUM4RKYUM4RKYUM4RKYUM4RKYU
Crafted since 2024
ZhenXiao Mark YuZhenXiao Mark Yu
get in touch

Saw something here?Tell me about it.

It's a portfolio, not a service · but I read every note — drop a line if anything here resonated, or just to say hi.

Start a conversation
open channel

say hi anytime · 2026

--:--:--ESTOntario, Canada
  • Email
  • GitHub
  • dev.to
  • LinkedIn
  • Twitter / X
  • Instagram
  • Facebook
  • YouTube
  • CodePen
  • Spotify
  • Snapchat

Newsletter

Get the occasional dispatch

Notes and logs from m4rkyu.com — short, dated, no noise. Unsubscribe anytime.

Work

Production builds, games, and visual archives.

  • Projects
  • Games
  • Archive
  • Logs

Resources

Daily-use tools and a personal link library.

  • Search
  • Latest
  • Tools
  • Links
  • Notes
  • Topics
  • Shop
RSSJSON feed

Studio

Background, contact, and channels for collaboration.

  • About
  • Contact
  • Changelog
  • Colophon
  • Resumepending

Socials

Find me on the usual feeds.

  • GitHub
  • dev.to
  • LinkedIn
  • Twitter / X
  • Instagram
  • Facebook
  • YouTube
  • CodePen
  • Spotify
  • Snapchat
  • Email
© 2026 ZhenXiao Mark Yumarkyu0615@gmail.com
  • Email
  • GitHub
  • dev.to
  • LinkedIn
  • Twitter / X
  • Instagram
  • Facebook
  • YouTube
  • CodePen
  • Spotify
  • Snapchat
PrivacyTermsBuilt with Next.js 16 · React 19 · Tailwind 4