Sikau

DevOps and deployment · Day 1 · about 25 min

Images and containers

Why containers exist; run, ps, logs, stop and rm.

"Works on my machine" — fixed

Your app needs Node 20, some packages and a config file. The server has Node 18. A container packages the app *with* everything it needs into an image, so it runs the same on your laptop, in CI and in production.

An image is a recipe plus all the ingredients, sealed. A container is one dish cooked from it — you can cook many from the same image.

The everyday commands

docker run hello-world
docker run -d -p 8080:80 --name web nginx:alpine
curl -s localhost:8080
docker ps
docker logs web
docker stop web
docker ps -a
docker rm web
docker images

The rest of this lesson

  • Containers versus virtual machinesexplain
  • The container lifecycleexplain
  • Two containers, one image?predict
  • Which command?match
  • Your turnwrite code
  • Badge quizquiz
  • What you learnedrecap

Continue this lesson free — run real code in your browser

Continue with Google

See all 14 lessons of DevOps and deployment