Basic Docker Commands cheat sheet

If you don’t know what Docker is check out this article what-is-docker

I have compiled a small list of the basic commands I find myself using mostly.

  • docker run – Runs a command in a new container.
  • docker start – Starts one or more stopped containers
  • docker stop – Stops one or more running containers
  • docker build – Builds an image form a Docker file
  • docker pull – Pulls an image or a repository from a registry
  • docker push – Pushes an image or a repository to a registry
  • docker export – Exports a container’s filesystem as a tar archive
  • docker exec – Runs a command in a run-time container
  • docker search – Searches the Docker Hub for images
  • docker attach – Attaches to a running container
  • docker ps – Shows all running containers
  • docker images – Shows a list of a ll images

Some additional useful commands:

  • docker exec -it <container name> bash – Steps into the command line of that container (this assumes bash is available in that container)
  • docker rm <container name> – remove a container
  • docker rm -v <container name> – remove a container and its volume
  • docker rmi <Imagename> <Imagename> – remove an image

Photo by Hannah Joshua