Index

Running a Container

100%Open SVG ↗
Lesson 2 -- Running a Container for Realan image is a frozen box. 'docker run' brings it to life -- isolated from the host, until you open exactly what it needs.1) WHAT 'docker run' ACTUALLY DOES$ docker run nginxdaemonregistrypull if missingnginxrunning containeryour CLI just asks the daemon; it pulls the image (once) and starts the box.2) ISOLATED FROM THE HOST -- you publish exactly what it needsCONTAINER (isolated)nginx serving :80/app -- its own filesystem-p 8080:80reach it at localhost:8080host ./data-v ./data:/app/data-e ENV=prodconfig at startits own network, filesystem, processes -- flags punch specific, deliberate holes.3) OPERATING A RUNNING BOXimagerunRUNNINGstopstoppedrmgonewhile it's running:docker ps list running boxesdocker logs peek at its outputdocker exec -it <box> sh open a shell INSIDE(exec is how you climb inside a live container to look around)YOUR WORLD -- one real shop run, every flag mapped:docker run -p 8081:8081 -v shop-secrets:/etc/shop -e ENV=prod users:latest-p users svc reachable on :8081 -v secrets mounted + kept alive -e which environment (image 'users:latest' pulled from your registry)JARGON: daemon = engine the CLI talks to | pull = fetch image from registry | volume = storage that outlives the box | exec = run a command in a live box

Lessons that use this board

Lesson 2 -- Running a Container for Real an image is a frozen box. 'docker run' brings it to life -- isolated from the host, until you open exactly what it needs. 1) WHAT 'docker run' ACTUALLY DOES $ docker run nginx daemon registry pull if missing nginx running container your CLI just asks the daemon; it pulls the image (once) and starts the box. 2) ISOLATED FROM THE HOST -- you publish exactly what it needs CONTAINER (isolated) nginx serving :80 /app -- its own filesystem -p 8080:80 reach it at localhost:8080 host ./data -v ./data:/app/data -e ENV=prod config at start its own network, filesystem, processes -- flags punch specific, deliberate holes. 3) OPERATING A RUNNING BOX image run RUNNING stop stopped rm gone while it's running: docker ps list running boxes docker logs peek at its output docker exec -it <box> sh open a shell INSIDE (exec is how you climb inside a live container to look around) YOUR WORLD -- one real shop run, every flag mapped: docker run -p 8081:8081 -v shop-secrets:/etc/shop -e ENV=prod users:latest -p users svc reachable on :8081 -v secrets mounted + kept alive -e which environment (image 'users:latest' pulled from your registry) JARGON: daemon = engine the CLI talks to | pull = fetch image from registry | volume = storage that outlives the box | exec = run a command in a live box

Saved in this browser only.

← The Shipping ContainerThe Recipe →