Lab 1: Docker First
Before Kubernetes, make sure you understand what it will be running.
1. Run the app with no container at all
Section titled “1. Run the app with no container at all”cd lab/appnode server.js# open http://localhost:3000 — you'll see ONE pod card (your hostname). Ctrl+C to stop.2. Build an image
Section titled “2. Build an image”cd labdocker build --target prod -t demo-app:1.0 appdocker images demo-appdocker history demo-app:1.0 # the layers3. Run containers
Section titled “3. Run containers”docker run -d --name one -p 3001:3000 demo-app:1.0docker run -d --name two -p 3002:3000 -e APP_COLOR=#ff6b6b demo-app:1.0curl -s localhost:3001/api/whoami; echocurl -s localhost:3002/api/whoami; echoSame image, two containers, different config. Open both in a browser.
4. Feel the pain Kubernetes solves
Section titled “4. Feel the pain Kubernetes solves”curl -X POST localhost:3001/api/crash # the app exits...docker ps -a --filter name=one # ...and stays dead (Exited (1))Nothing brought it back, nothing load-balances between one and two, and running it on another machine is up to you. (docker run --restart=always helps with the first problem, on one machine only.)
5. Clean up
Section titled “5. Clean up”docker rm -f one twoTakeaway: Docker packages and runs. Kubernetes keeps things running across machines.