Skip to content

Instantly share code, notes, and snippets.

@techniq
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techniq/da873605e6ea8e40dcc5 to your computer and use it in GitHub Desktop.
Save techniq/da873605e6ea8e40dcc5 to your computer and use it in GitHub Desktop.
Docker Helpers
# Get the last container ID
alias docker-last="docker ps -l"
# Get a container's IP
alias docker-get-ip="docker inspect --format '{{ .NetworkSettings.IPAddress }}'"
# Get a container's image
alias docker-get-image="docker inspect --format '{{ .Image }}'"
# Remove all exited docker containers
docker-rm-all() { docker rm $(docker ps -aq); }
# Remove all untagged docker images
docker-rm-untagged-images() { docker rmi `docker images | awk '{if ($2 == "<none>") print $3}' | xargs`; }
#clean up all docker containers and untagged images
docker-clean() { docker-rm-all; docker-rm-untagged-images; }
# Shorthand for docker build
db() { docker build -t="$1" .; }
# Add aliases to shell. Run `. ./setup-shell.sh` (not the leading `.` and space)
alias ansible='docker run -v "$(pwd):/app" -w "/app" -it --rm ansible/ubuntu14.04-ansible ansible --private-key=.ssh/id_rsa'
alias ansible-playbook='docker run -v "$(pwd):/app" -w "/app" -it --rm ansible/ubuntu14.04-ansible ansible-playbook --private-key=.ssh/id_rsa'
alias ansible-shell='docker run -v "$(pwd):/app" -w "/app" -it --rm ansible/ubuntu14.04-ansible bash'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment