Docker cheatsheet

To check if a container is running in priviledged mode

1docker inspect --format='{{.HostConfig.Privileged}}' <container id>
 1# list available images
 2$ docker images ls
 3# list running containers
 4$ docker ps
 5# list running AND stopped containers
 6$ docker ps -a
 7# run a command in a running container
 8$ docker exec -ti <container-name-or-first-letters-of-id> bash
 9# follow logs of a running container
10$ docker logs -f <container-name-or-first-letters-of-id>
11# delete unused images to free up disk space
12$ docker system prune --images
13# delete unused volumes to free up disk space (CAUTION all data in unused volumes will be lost)
14$ docker system prune --volumes
15# delete unused containers
16$ docker system prune

References

  1. https://www.digitalocean.com/community/tutorials/how-to-remove-docker-images-containers-and-volumes
  2. https://www.docker.com/sites/default/files/d8/2019-09/docker-cheat-sheet.pdf