DEV Community

Cover image for Useful Docker shell aliases to speed up Development

Useful Docker shell aliases to speed up Development

Kevin Woblick on August 31, 2019

I work with Docker all the time. Ditching my MAMP stack for Docker was one of the most convenient and useful decisions I've ever made. If you are i...
Collapse
 
danielkun profile image
Daniel Albuschat

Nice cheat-sheet, thanks!

I can add:

# Remove stopped containers, unused images, unused networks, etc.:
alias dsp="docker system prune"
Enter fullscreen mode Exit fullscreen mode

I'd recommend starting all alias names with a common prefix, so that you can list the available aliases with tab-completion. Something uncommon like dk or something. Then you can do dk<TAB> and see all your aliases.

Collapse
 
abhinav1217 profile image
Abhinav Kulshreshtha • Edited

Good to know I am not the only one with this idea. I prefix all my tool related alias like fld_prune = docker system prune and flk_delete = kubectl delete. fl is my handler, fld_ are my docker alias, flk_ are kube related aliases. fly_ are youtube-dl related alias. Only tools related aliases are prefixed, common aliases are not prefixed so cls=clear and md=mkdir -p are unprefixed.

Collapse
 
m1well profile image
Michael Wellner

I also have a cheatsheet and a respondiere tool with wich i could take a look at the cheatsheet via shell and execute commands instantly.
Also including some predefined databases.
Cheatsheet: github.com/m1well/env-setup/blob/m...
Tool: github.com/m1well/cheatsheet

Collapse
 
rikvanderkemp profile image
Rik van der Kemp • Edited

Cool! You can simplify your docker stop command like this (if you want)

docker stop $(docker ps -q)

edit: remove 'a' from the ps command

Collapse
 
kovah profile image
Kevin Woblick

You can speed up this command by simply removing the a flag. It gets all Docker containers, even those which are stopped, which makes no sense for stopping all containers.

Collapse
 
rikvanderkemp profile image
Rik van der Kemp

You are right, also using this to remove all so got confused 😜

Collapse
 
jwkicklighter profile image
Jordan Kicklighter

Also dce="docker-compose exec -it

Collapse
 
ajboni profile image
ajboni

I've been using something similar for kubernetes and it's a life changer. (github.com/ahmetb/kubectl-aliases)
maybe we should make a docker repo?

Collapse
 
frankfont profile image
Frank Font

My work buddies and I took the alias idea to next level and created github.com/bah-insignia/zcmd

Collapse
 
felipe1982 profile image
Felipe Alvarez

That's for docker compose. Not docker.