dotfiles/.bash_it/aliases/available/docker.aliases.bash
2022-02-27 20:00:49 +01:00

44 lines
2.2 KiB
Bash

cite 'about-alias'
about-alias 'docker abbreviations'
alias dk='docker'
alias dklc='docker ps -l' # List last Docker container
alias dklcid='docker ps -l -q' # List last Docker container ID
alias dklcip='docker inspect -f "{{.NetworkSettings.IPAddress}}" $(docker ps -l -q)' # Get IP of last Docker container
alias dkps='docker ps' # List running Docker containers
alias dkpsa='docker ps -a' # List all Docker containers
alias dki='docker images' # List Docker images
alias dkrmac='docker rm $(docker ps -a -q)' # Delete all Docker containers
case $OSTYPE in
darwin*|*bsd*|*BSD*)
alias dkrmui='docker images -q -f dangling=true | xargs docker rmi' # Delete all untagged Docker images
;;
*)
alias dkrmui='docker images -q -f dangling=true | xargs -r docker rmi' # Delete all untagged Docker images
;;
esac
if [ ! -z "$(command ls "${BASH_IT}/enabled/"{[0-9][0-9][0-9]${BASH_IT_LOAD_PRIORITY_SEPARATOR}docker,docker}.plugin.bash 2>/dev/null | head -1)" ]; then
# Function aliases from docker plugin:
alias dkrmlc='docker-remove-most-recent-container' # Delete most recent (i.e., last) Docker container
alias dkrmall='docker-remove-stale-assets' # Delete all untagged images and exited containers
alias dkrmli='docker-remove-most-recent-image' # Delete most recent (i.e., last) Docker image
alias dkrmi='docker-remove-images' # Delete images for supplied IDs or all if no IDs are passed as arguments
alias dkideps='docker-image-dependencies' # Output a graph of image dependencies using Graphiz
alias dkre='docker-runtime-environment' # List environmental variables of the supplied image ID
fi
alias dkelc='docker exec -it $(dklcid) bash --login' # Enter last container (works with Docker 1.3 and above)
alias dkrmflast='docker rm -f $(dklcid)'
alias dkbash='dkelc'
alias dkex='docker exec -it ' # Useful to run any commands into container without leaving host
alias dkri='docker run --rm -i '
alias dkric='docker run --rm -i -v $PWD:/cwd -w /cwd '
alias dkrit='docker run --rm -it '
alias dkritc='docker run --rm -it -v $PWD:/cwd -w /cwd '
# Added more recent cleanup options from newer docker versions
alias dkip='docker image prune -a -f'
alias dkvp='docker volume prune -f'
alias dksp='docker system prune -a -f'