Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at


Dockerを便利に使うためのalias | SOTA を参考にさせていただきながら自分なりのエイリアスを作ってみた。

# ------------------------------------
# Docker aliases
# ------------------------------------

alias d="docker"

# Get the latest container ID
alias dl="docker ps --latest --quiet"

# List containers
alias dps="docker ps"

# List containers including stopped containers
alias dpa="docker ps --all"

# List images
alias di="docker images"

# List images including intermediates
alias dia="docker images --all"

# Tree images including intermediates
alias dit="docker images --tree"

# Get an IPaddress of a container
alias dip="docker inspect --format '{{ .NetworkSettings.IPAddress }}'"

# Run a daemonized container
alias drd="docker run --detach --publish-all"

# Run an interactive container 
alias dri="docker run --interactive --tty --publish-all"

# Remove all containers
alias drm='docker rm $(docker ps --all --quiet)'

# Remove all images
alias drmi='docker rmi $(docker images --quiet)'

# Remove all containers and images by force
alias dclean='docker kill $(docker ps --all --quiet); drm; drmi;'

# List all aliases relating to docker
dalias() { alias | grep 'docker' | sed "s/^\([^=]*\)='\(.*\)'/\1    => \2/"| sed "s/'\\\'//g"; }

※) 最後の /\1 => の部分は スペース1+タブ1 にしてみました。

$ dalias
alias d         => docker
alias dclean    => docker kill $(docker ps --all --quiet); drm; drmi;
alias di        => docker images
alias dia       => docker images --all
alias dip       => docker inspect --format '{{ .NetworkSettings.IPAddress }}'
alias dit       => docker images --tree
alias dl        => docker ps --latest --quiet
alias dpa       => docker ps --all
alias dps       => docker ps
alias drd       => docker run --detach --publish-all
alias dri       => docker run --interactive --tty --publish-all
alias drm       => docker rm $(docker ps --all --quiet)
alias drmi      => docker rmi $(docker images --quiet)
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
Help us understand the problem. What are the problem?