Skip to content
SoftwareSolutions.net
Cheat sheet

Docker Basic Commands Cheat Sheet

The everyday Docker commands for running containers, checking images, reading logs and cleaning up, with one line of explanation each.

Docker runs applications in containers. An image is the template, and a container is a running copy of it.

Images

  • docker pull image: download an image
  • docker images: list downloaded images
  • docker build -t name . : build an image from a Dockerfile
  • docker rmi image: remove an image

Containers

  • docker run -it image: run an image with an interactive terminal
  • docker run -d -p 8080:80 image: run in the background, port 8080 to 80
  • docker ps: list running containers
  • docker stop name: stop a container

Logs and cleanup

  • docker logs name: show a container's output
  • docker exec -it name sh: open a shell inside a running container
  • docker system prune: remove unused data