Skip to content

Docker Basic Commands

Mattias Martikainen edited this page Aug 8, 2018 · 10 revisions

A small list of the commands most often used

Container commands

  • docker ps Check running containers

  • docker ps -a Check all containers

  • docker ps -s Check soze of running containers

  • docker ps -as Check size of all containers

  • docker stop nameofcontainer stopping a container

  • docker start nameofcontainer starting a container

  • docker restart nameofcontainer restarting a container

  • docker rm nameofcontainer !Removes container!

  • docker exec -it nameofcontainer bash lets you "ssh" to the container so you can troubleshoot and other stuff.

Images commands

  • docker images -a Check images available
  • docker rmi nameofimage Removes image
  • docker inspect --format='{{.Id}} {{.Parent}}' $(docker images --filter since=97256f68a60a -q) removing any child images to the image specified after "since="

Deleting all containers/images

Warning, do not use this if you haven't saved your startup commands and used external storage for configs.

  • docker kill $(docker ps -q) Kill all running containers
  • docker rm $(docker ps -a -q) Delete all stopped containers (including data-only containers)
  • docker rmi $(docker images -q -f dangling=true) Delete all 'untagged/dangling' () images
  • docker rmi $(docker images -q) Delete ALL images

Host Commands

  • sudo service docker status check status of docker service

  • sudo service docker restart restarts docker service

  • 'ncdu' - check storage space

Clone this wiki locally