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
- Run your first container
- Check your versions
- Run a real service
- List what's running
- Read the logs
- Step inside the container
- Stop the container
- See stopped containers too
- Remove the container
- List your images
- Pull an image ahead of time
- Write a Dockerfile
- Add the page to serve
- Build the image
- Run your own image
- Stop and clear the way
- Prepare a folder to mount
- Mount a host folder
- Confirm the mount is live
- Pass environment variables
- Inspect a container
- Pull one field for a script
- Tidy up before Compose
- Describe a stack with Compose
- Bring the stack up
- List the stack
- Tear the stack down
- Remove an image
- Reclaim space, carefully
- Where to go from here