Essential Docker Commands

The core Docker CLI commands every beginner needs: pull, run, ps, logs, exec, stop, and rm.

A compact mental map

Docker commands fall into a few natural groups: working with images, managing containers, and inspecting what is running. You will reach for the same eight or so commands in almost every session.

The essential starter commands

docker pull nginx           # download an image from Docker Hub
docker run -d -p 8080:80 nginx  # start container in background, map ports
docker ps                   # list running containers
docker ps -a                # list all containers including stopped
docker logs <name or id>    # view container output
docker exec -it <name> /bin/bash  # open shell inside running container
docker stop <name or id>    # send stop signal to container
docker rm <name or id>      # delete a stopped container

Run them one at a time and read the output carefully. Each command prints helpful information about what happened.

You can use the first few characters of a container ID instead of the full ID. Docker will match it as long as those characters are unique.

Focus on meaning, not memorization

Instead of memorising every flag, understand what each command represents in the container lifecycle.

  • pull — fetch the image template
  • run — create and start a container from an image
  • ps — see what is alive right now
  • logs — read what the container has been printing to stdout
  • exec — step inside a running container for debugging
  • stop — ask the container to shut down gracefully
  • rm — clean up containers you no longer need

With these seven concepts you can handle most day-to-day Docker work. Everything else builds on top of them.