Skip to content

Instantly share code, notes, and snippets.

@JonasAlfredsson
Last active April 16, 2020 14:20
Show Gist options
  • Save JonasAlfredsson/8f278acfe8bc13cd866a76cc83de3b40 to your computer and use it in GitHub Desktop.
Save JonasAlfredsson/8f278acfe8bc13cd866a76cc83de3b40 to your computer and use it in GitHub Desktop.
Useful Docker Functions
# Docker Functions
# A small collection of commands that can be quite useful when
# working with Docker.
# Stop all containers on the system.
stop_all_containers() {
docker stop $(docker ps -aq)
}
# Stop all containers on the system and remove them.
remove_all_containers() {
docker stop $(docker ps -aq)
docker rm $(docker ps -aq)
}
# Find, kill and completely remove any and all Docker containers,
# images, volumes and networks that might be hiding on your system.
docker_armageddon() {
remove_all_containers
docker network prune -f
docker rmi -f $(docker images --filter dangling=true -qa)
docker volume rm $(docker volume ls --filter dangling=true -q)
docker rmi -f $(docker images -qa)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment