Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Some useful shell aliases and function for Docker command line
# Docker aliases
alias di='sudo docker images'
alias dps='sudo docker ps -a'
# useful Docker functions
dock-run() { sudo docker run -i -t --privileged $@ ;}
dock-exec() { sudo docker exec -i -t $@ /bin/bash ;}
dock-log() { sudo docker logs --tail=all -f $@ ;}
dock-port() { sudo docker port $@ ;}
dock-vol() { sudo docker inspect --format '{{ .Volumes }}' $@ ;}
dock-ip() { sudo docker inspect --format '{{ .NetworkSettings.IPAddress }}' $@ ;}
dock-rmc() { sudo docker rm `sudo docker ps -qa --filter 'status=exited'` ;}
dock-rmi() { sudo docker rmi -f `sudo docker images | grep '^<none>' | awk '{print $3}'` ;}
dock-do() {
if [ "$#" -ne 1 ]; then
echo "Usage: $0 start|stop|pause|unpause|<any valid docker cmd>"
fi
for c in $(sudo docker ps -a | awk '{print $1}' | sed "1 d")
do
sudo docker $1 $c
done
}
@KylePalko

This comment has been minimized.

Copy link

@KylePalko KylePalko commented Jun 30, 2016

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.