Published on

Docker Command Line Aliases for Increased Productivity

Authors

When working with docker especially via Kubernetes it can get pretty cumbersome having to stop all containers and delete them. My general work flow is:

  • Docker compose the containers I need.
  • Do the dev on my app that runs against these containers.
  • When I'm done stop all containers.
  • Delete all stopped containers.

To simplify this work flow I setup the following aliases in my .bashrc file:

# stop all containers
alias dockersac='docker kill $(docker ps -q)'
# delete all stopped containers
alias dockerdsc='docker rm $(docker ps -a -q)'
# delete all dangling images (i.e. images that have no name)
alias dockerdi='docker rmi $(docker images -q -f dangling=true)'
# delete all images not just unused (this will wipe all docker images off your machine)
alias dockernuke='docker rmi $(docker images -q)'

Over time Docker images can end up chewing hard disk space. I find the easiest is to wipe all my docker images and build my local cache over time again hence the reason for the last alias.