Skip to content

Docker Quick Reference Commands

Action Command Example Info
Attach container docker container attach container-name-or-id
List container ports docker container port container-name-or-id List port mappings or a specific mapping for the container.
List containers docker container ls
List containers docker ps
List images docker image ls
List images docker images
List volumes docker volume ls
Remove containers docker container prune Remove all stopped containers.
Remove containers docker container rm container-name-or-id
Remove image docker image rm image-id
Remove unused volumes docker volume prune Remove all unused local volumes.
Remove volume docker volume rm volume-id
Restart container docker restart container-name-or-id
Run shell command docker container exec -it container-name-or-id ls /var The command will be executed within the shell container.
Show container details docker container inspect container-name-or-id Display detailed information on one or more containers.
Show container logs docker logs container-name-or-id
Show container processes docker top container-name-or-id
Show container stats docker stats container-name-or-id
Start container docker start container-name-or-id
Start shell session docker container exec -it container-name-or-id /bin/bash
Stop container docker kill container-name-or-id Forcedly stop a container.
Stop container docker stop container-name-or-id


  • To detach from the container without stopping it, press CTRL-P CTRL-Q
  • To detach from a container by stopping it press CTRL-C

Last update: March 16, 2023