Skip to content

Instantly share code, notes, and snippets.

@BenjaminHerbert
Last active August 29, 2015 14:05
Show Gist options
  • Save BenjaminHerbert/0ce28721193efe8e7c8a to your computer and use it in GitHub Desktop.
Save BenjaminHerbert/0ce28721193efe8e7c8a to your computer and use it in GitHub Desktop.
docker shortcuts
# From http://kartar.net/2014/03/some-useful-docker-bash-functions-and-aliases/
# Docker container IP
alias dip="docker inspect --format '{{ .NetworkSettings.IPAddress }}'"
#Removing containers
drm() { docker rm $(docker ps -q -a); }
#Removing images
dri() { docker rmi $(docker images -q); }
#Run a daemonized container with port mapping
alias dkd="docker run -d -P"
#Run an interactive container with port mapping
alias dki="docker run -t -i -P"
# build a container and make it a tag - assumes a Dockerfile in the current directory.
db() { docker build -t="$1" .; }
# remove dangling images (dangling=="untagged images, that are the leaves of the images tree (not intermediary layers)" - https://docs.docker.com/reference/commandline/cli/#images)
docker rmi $(docker images -q --filter "dangling=true")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment