[Tips] Docker aliases with zsh using Ohmyzsh
I use ohmyzsh as my preferred shell setup. I also use Docker. Recently, I've been focused on automating the setup and teardown of my applications. This is where ohmyzsh's excellent support for docker comes in, as it has many aliases that help with shortening the use of common tasks:
You can add it to your .zshrc
plugin list:
When you restart your shell, you'll have access to commands like
dipru
(docker image prune -a
),dps
(docker ps
) anddvls
(docker volume ls
).
Additionally, if you enable stacking, you'll able to pass options to aliases like dcls
(docker container ls
). However, be aware of the following issue:
This enables Zsh to understand commands like
docker run -it ubuntu
. However, by enabling this, this also makes Zsh completedocker run -u<tab>
withdocker run -uapprox
which is not valid. The users have to put the space or the equal sign themselves before trying to complete.
Anyways, that's it for today! Ohmyzsh gives us many tools out of the box, docker aliases with autocompletion is one of them. Enable it and you'll have access to many commands you won't need to maintain yourself.
References
Subscribe to my newsletter
Read articles from Alvin Crespo directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Alvin Crespo
Alvin Crespo
Hi, I’m Alvin! I write about tech, and love sharing what I learn. If you have any questions or suggestions, please reach out - I'm always up for a quick chat.