Docker References#


Debugging#

Shell Into Running Docker Container#

Shell into a running container by using exec and enabling interactive (-i) and tty (-t). This can be used to run any commands though running a shell is the most useful for debugging.

1# syntax
2docker exec -it <docker_container> <command>
3
4# example
5docker exec –it nginx /bin/bash

Cleanup#

Purge All Unused or Dangling Images, Containers, Volumes, and Networks#

1# remove all dangling docker artifacts
2docker system prune -a
3
4# remove dangling volumes
5docker volume prune

Remove All Exited Containers#

1docker rm $(docker ps -a -f status=exited -q)

Stop and Remove All Containers#

1docker stop $(docker ps -a -q)
2docker rm $(docker ps -a -q)

Remove All Docker Images#

1docker rmi $(docker images -a -q)