Running a Container
Tap the board to zoom inClick the board to zoom in
Lessons that use this board
- Running a Container for Reallesson
- Linux and the Shell: Processes, Files, Pipes, Permissions and Signalslesson
- Build Your Own Container Runtimelesson
- Container 06: A Network Namespace and a Virtual Cablelesson
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.