DEV Community

Alvin Crespo
Alvin Crespo

Posted on

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:

.zshrc - plugins

When you restart your shell, you'll have access to commands like

  • dipru (docker image prune -a)
  • dps (docker ps)
  • dvls (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 complete docker run -u with docker 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

Ohmyzsh

Docker

ohmyzsh - docker reference

docker system prune

docker image prune

docker container ls

docker volume ls

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay