← All bricks

docker · Beginner

docker: Containers from the Command Line

Get fluent with the docker command-line client — run containers, map ports, read logs, build images from a Dockerfile, mount volumes, pass environment, and bring up a multi-service stack with Compose.

Most people meet Docker through a dashboard and never learn the client that does the real work. The docker CLI is faster, scriptable, and always there on the box you just SSH'd into. We start by running a container and build up genuine fluency one small thing at a time: mapping ports, reading logs, stepping inside a running container, building your own image from a Dockerfile, mounting a folder from the host, passing environment, and finally bringing up a web-plus-database stack with Compose. Writing a Dockerfile and building it are taught as separate things, so each idea lands on its own.

What you'll build

  • Run, list, and stop containers from the command line
  • Map ports and read container logs
  • Build your own image from a Dockerfile
  • Mount host folders and pass environment variables
  • Inspect containers and script around them
  • Bring up a multi-service stack with Compose

Contents

  1. Run your first container
  2. Check your versions
  3. Run a real service
  4. List what's running
  5. Read the logs
  6. Step inside the container
  7. Stop the container
  8. See stopped containers too
  9. Remove the container
  10. List your images
  11. Pull an image ahead of time
  12. Write a Dockerfile
  13. Add the page to serve
  14. Build the image
  15. Run your own image
  16. Stop and clear the way
  17. Prepare a folder to mount
  18. Mount a host folder
  19. Confirm the mount is live
  20. Pass environment variables
  21. Inspect a container
  22. Pull one field for a script
  23. Tidy up before Compose
  24. Describe a stack with Compose
  25. Bring the stack up
  26. List the stack
  27. Tear the stack down
  28. Remove an image
  29. Reclaim space, carefully
  30. Where to go from here