Docker from Zero: What Every Flag in `docker run` Actually Does
Most Docker introductions start with abstract concepts; this one anchors every term to a single, real command a developer would actually type. The progression from `docker run` flags to Dockerfile, multi-stage builds, and Compose mirrors the path from quick experiment to production setup, giving a newcomer the full arc in one sitting.
Starting from a concrete problem — running an Nginx reverse proxy for a local Node.js service without polluting the host — the piece unpacks every flag in `docker run --name my-nginx-demo -p 80:80 -v ... -d nginx`. It explains images as layered, read-only templates; containers as stateless running instances; port mapping as the bridge between host and container network stacks; and bind mounts as the mechanism for injecting host files like `nginx.conf`.
A dedicated section covers the `host.docker.internal` DNS name that Docker Desktop provides so containers can reach services on the host, a common pain point when a reverse proxy runs containerized but the backend does not. The article then builds toward production patterns: writing a Dockerfile for the Node service, using `.dockerignore` to keep images small, multi-stage builds to strip dev dependencies, and Docker Compose to orchestrate both services so they communicate by service name instead of host hacks.
A command-reference table and a side-by-side comparison of containers versus virtual machines round out the piece, making it useful as both a tutorial and a cheat sheet.
Teaching Docker through a single, flawed command — and then fixing each misconception — is more effective than listing concepts in isolation. The `docker run` invocation becomes a syllabus.
The `host.docker.internal` workaround is a Docker Desktop crutch that vanishes when both services are containerized and placed on the same Compose network, which is the real end state worth aiming for.
Bind mounts are the right call for config injection during development, but the article correctly flags that Volumes are the production choice — a distinction many tutorials blur.