Last active
December 3, 2016 21:45
-
-
Save oscarruesga/6a047af00b1ed7cafb5c6d053f0ac8a5 to your computer and use it in GitHub Desktop.
Docker Utils
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# add 'source <pathToThisFile>/docker-util.sh' to ~/.bashrc. This makes this functions available in the current shell. | |
docker-stop-remove(){ | |
docker stop $1 && docker rm $1 | |
} | |
docker-remove-stopped(){ | |
#docker rm $(docker ps -a -q) | |
docker ps -a -q | xargs docker rm | |
} | |
docker-nuke() { | |
docker ps -q | xargs docker stop | |
docker ps -q -a | xargs docker rm | |
} | |
docker-rmi-none() { | |
docker images | grep '<none>' | \ | |
awk '{ print $3 }' | \ | |
xargs docker rmi | |
} | |
docker-go() { | |
docker run --rm -t -i $@ | |
} | |
docker-go-bg() { | |
docker run -d --name $@ $@ | |
} | |
# append bash in a running container | |
docker-exec-bash(){ | |
if [ $# -lt 1 ] ; then | |
echo "Please provide a container id or name. Usage: docker-exec-bash <containerIdOrName>" | |
else | |
docker exec -it $1 bash | |
fi | |
} | |
# show running processes within a running container | |
docker-container-ps(){ | |
docker exec $1 ps -f | |
} | |
# Removing orphaned Docker volumes | |
docker-del-orphan-volumes(){ | |
docker volume ls -qf dangling=true | xargs -r docker volume rm | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment