DEV Community

Cover image for Useful aliases for docker
Rubin
Rubin

Posted on

2 1

Useful aliases for docker

Docker has been there for a long time and its my top most used tool whether for spinning up a web server or trying out a new tool.
If you are like me and use docker on your day to day dev workflow, these aliases would help you save few keystrokes for common use cases and save your time.
You can set up in your shell configuration file (like .bashrc, .zshrc, etc.):

Get latest container ID

alias dl="docker ps -l -q"
Enter fullscreen mode Exit fullscreen mode

Get container process

alias dps="docker ps"
Enter fullscreen mode Exit fullscreen mode

Get process included stop container

alias dpa="docker ps -a"
Enter fullscreen mode Exit fullscreen mode

Get images

alias di="docker images"
Enter fullscreen mode Exit fullscreen mode

Get container IP

alias dip="docker inspect --format '{{ .NetworkSettings.IPAddress }}'"
Enter fullscreen mode Exit fullscreen mode

Run daemonized container, e.g., $dkd base /bin/echo hello

alias dkd="docker run -d -P"
Enter fullscreen mode Exit fullscreen mode

Run interactive container, e.g., $dki base /bin/bash

alias dki="docker run -i -t -P"
Enter fullscreen mode Exit fullscreen mode

Execute interactive container, e.g., $dex base /bin/bash

alias dex="docker exec -i -t"
Enter fullscreen mode Exit fullscreen mode

Stop all containers

alias dstop='docker stop $(docker ps -a -q)'
Enter fullscreen mode Exit fullscreen mode

Remove all containers

alias drm='docker rm $(docker ps -a -q)'
Enter fullscreen mode Exit fullscreen mode

Stop and Remove all containers

alias drmf='docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q)'
Enter fullscreen mode Exit fullscreen mode

Remove all images

alias dri='docker rmi $(docker images -q)'
Enter fullscreen mode Exit fullscreen mode

Dockerfile build, e.g., $dbu tcnksm/test

alias dbu='docker build -t=$1 .'
Enter fullscreen mode Exit fullscreen mode

Show all alias related docker

dalias() { alias | grep 'docker' | sed "s/^\([^=]*\)=\(.*\)/\1 => \2/" | sed "s/['|\']//g" | sort; }
Enter fullscreen mode Exit fullscreen mode

Bash into running container

alias dbash='docker exec -it $(docker ps -aqf "name=$1") bash'
Enter fullscreen mode Exit fullscreen mode

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

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