Home

Awesome

zsh-containers

zsh-containers is a zsh plugin that provides aliases and better interoperability between podman and docker commands based on which you have installed.

installing

zinit

Add this to your zinit config (.zshrc):

zinit light redxtech/zsh-containers

# it also works with turbo mode:
zinit ice wait lucid
zinit load redxtech/zsh-containers

oh-my-zsh

Install it with your favourite zsh package manager, or clone it directly to your $ZSH_CUSTOM/plugins directory with git, and add containers to the plugins array in your .zshrc file:

plugins=(... containers)

completion

i would recommend using greymd/docker-zsh-completion for up-to-date completions pulled weekly from upstream.

podman -> docker

since podman and docker commands are mostly interchangable, people will often use alias docker="podman", and it usually works fine - however, if you also use docker compose, it might be not work if you run compose via docker compose, since podman compose isn't a command - you have to run podman-compose, which isn't exactly compatible with the alias method.

to solve that, i've made a docker function, that detects if the first argument is compose. if that's the case, it removes that argument, and passes the rest to podman-compose. for any other first argument, it passes them all to podman.

if you don't use podman or podman-compose, then this plugin won't change any of this.

docker aliases

AliasCommandDescription
dbldocker buildBuild an image from a Dockerfile
dcindocker container inspectDisplay detailed information on one or more containers
dclsdocker container lsList all the running docker containers
dclsadocker container ls -aList all running and stopped containers
dibdocker image buildBuild an image from a Dockerfile (same as docker build)
diidocker image inspectDisplay detailed information on one or more images
dilsdocker image lsList docker images
dipudocker image pushPush an image or repository to a remote registry
dirmdocker image rmRemove one or more images
ditdocker image tagAdd a name and tag to a particular image
dlodocker container logsFetch the logs of a docker container
dncdocker network createCreate a new network
dncndocker network connectConnect a container to a network
dndcndocker network disconnectDisconnect a container from a network
dnidocker network inspectReturn information about one or more networks
dnlsdocker network lsList all networks the engine daemon knows about, including those spanning multiple hosts
dnrmdocker network rmRemove one or more networks
dpodocker container portList port mappings or a specific mapping for the container
dpudocker pullPull an image or a repository from a registry
drdocker container runCreate a new container and start it using the specified command
dritdocker container run -itCreate a new container and start it in an interactive shell
drmdocker container rmRemove the specified container(s)
drm!docker container rm -fForce the removal of a running container (uses SIGKILL)
dstdocker container startStart one or more stopped containers
drsdocker container restartRestart one or more containers
dstadocker stop $(docker ps -q)Stop all running containers
dstpdocker container stopStop one or more running containers
dtopdocker topDisplay the running processes of a container
dvidocker volume inspectDisplay detailed information about one or more volumes
dvlsdocker volume lsList all the volumes known to docker
dvprunedocker volume pruneCleanup dangling volumes
dxcdocker container execRun a new command in a running container
dxcitdocker container exec -itRun a new command in a running container in an interactive shell

docker compose aliases

AliasCommandDescription
dcodocker-composeDocker-compose main command
dcbdocker-compose buildBuild containers
dcedocker-compose execExecute command inside a container
dcpsdocker-compose psList containers
dcrestartdocker-compose restartRestart container
dcrmdocker-compose rmRemove container
dcrdocker-compose runRun a command in container
dcstopdocker-compose stopStop a container
dcupdocker-compose upBuild, (re)create, start, and attach to containers for a service
dcupbdocker-compose up --buildSame as dcup, but build images before starting containers
dcupddocker-compose up -dSame as dcup, but starts as daemon
dcupdbdocker-compose up -d --buildSame as dcup, but build images before starting containers and starts as daemon
dcdndocker-compose downStop and remove containers
dcldocker-compose logsShow logs of container
dclfdocker-compose logs -fShow logs and follow output
dcpulldocker-compose pullPull image of a service
dcstartdocker-compose startStart a container
dckdocker-compose killKills containers

credit

thanks to the docker and docker-compose oh-my-zsh plugins for inspiration for the aliases.

author

zsh-containers © gabe dunn, released under the MIT License.