🚀 Containers: docker run

Containers: docker run: docker run is the moment a blueprint becomes a building: the image is the frozen architectural plan, and 'docker run' pours the concrete, wires the electr

docker run is the moment a blueprint becomes a building: the image is the frozen architectural plan, and 'docker run' pours the concrete, wires the electricity, and hands over the keys — a live container with its own filesystem, network port, and name. So why does one single command need flags like -d, -p, and --name instead of just 'launch it'? Because each flag configures a DIFFERENT layer of that construction — exactly the way a Java constructor's parameters configure one object instance while the class file stays untouched: you can 'new' ten instances from one class, and you can run ten containers from one image. For QA this is daily bread: a wrong -p port mapping is the classic reason your Selenium test suddenly cannot reach localhost:8080 even though the app container looks 'green' — the app is fine, your door number is wrong.

Starting a container — the basics

This is exactly mission 2 in the sandbox in the next tab ("🔄 Lifecycle & Debug"): type docker run -d -p 8080:80 --name web nginx and watch the green pulsing box appear in the CONTAINERS panel.

Production-style run — all common flags together

What Does Each Flag in a Production-Style docker run Configure?

-d and --name configure HOW the…

`-d` and `--name` configure HOW the container runs (in the background, under a specific name) — they say NOTHING about the APPLICATION yet.

-p and -e wire the connection to the…

`-p` (port) and `-e` (environment variable) wire the container's connection to the OUTSIDE world (network) and its OWN behavior (config) — each configures a DIFFERENT layer.

-v and --restart configure PERSISTENCE…

`-v` (volume) and `--restart` define the rules for KEEPING data even if the container is REMOVED, and for SELF-RECOVERING if it CRASHES — the two most critical flags in production.

If EVEN ONE of these flags is…

If EVEN ONE of these flags is missing or wrong (a wrong port, a forgotten `-v`), the bug is USUALLY not in the app code — it's a typo on THIS line.

Practice: Complete a production-style run command