# Demonstration: `run` Creates, `exec` Reaches In ## OBSERVE ``` $ docker run -d --name web nginx:alpine $ docker ps --format '{{.Names}}' web ``` One container exists. ## HYPOTHESIS Predict: will `docker exec web echo hello` create a SECOND container? ## INSPECT ``` $ docker exec web echo hello hello $ docker ps --format '{{.Names}}' web ``` Still exactly one container — `exec` ran a new command INSIDE the existing one, it never created anything new. ## CHANGE Now actually run the same image again: ``` $ docker run -d --name web2 nginx:alpine $ docker ps --format '{{.Names}}' web2 web ``` Now two containers exist — because `run`, unlike `exec`, always creates a NEW container. ## VERIFY ``` $ docker logs web | tail -3 $ docker inspect web --format '{{.State.Running}}' true ``` Both containers are independent, each with their own logs and state — exactly as Module 2's "one image, many containers" demonstration showed. ## Instructor Notes **Demo goal:** Directly contrast `run` and `exec`'s effect on the container COUNT — this is the most common early confusion and deserves a side-by-side comparison. **Approximate timing:** 8 minutes live. **Common mistake to watch for:** trying to `exec` into a container that isn't running yet (`exec` requires an ALREADY-running target) — a good moment to connect back to `docker ps` first.