Last active
January 16, 2016 08:18
-
-
Save abn/1513dcc2ed4e1ca8d86a to your computer and use it in GitHub Desktop.
.bashrc additions for docker sugar
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
# .bashrc.docker | |
# get id of last container started | |
docker-last() { docker ps -l -q ;} | |
# http://www.commandlinefu.com/commands/view/15050/attach-to-bash-shell-in-the-last-container-you-started | |
docker-exec() { docker exec -i -t $(docker-last) ${@-bash} ;} | |
# get ip of container with given id (default: last started container) | |
docker-ip() { docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${1-$(docker-last)} ;} | |
# bring down docker bridge | |
docker-delbr() { | |
BRIDGE=${1-docker0} | |
sudo ip link set ${BRIDGE} down | |
sudo brctl delbr ${BRIDGE} | |
} | |
# fix selinux permissions for use in docker containers | |
docker-chcon() { [[ $# -gt 0 ]] && chcon -Rt svirt_sandbox_file_t $@ ;} | |
# clean-up cache | |
docker-clean() { | |
for d in $(docker ps -a -q); do | |
docker stop $d || true | |
docker rm $d || true | |
done | |
docker images | grep \<none\> | awk '{print $3}' \ | |
| xargs -I {} docker rmi --force {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment