Docker bash aliases - new bash shell commands to make working with Docker containers & images easier.
Save the docker_aliases.sh
file to your home directory. Rename it to .docker_aliases
:
curl https://raw.githubusercontent.com/dflock/docker_aliases/master/docker_aliases.sh > ~/.docker_aliases
Then and add this to your ~/.bashrc
file somewhere:
if [ -f ~/.docker_aliases ]; then
source ~/.docker_aliases
fi
Then either close & re-open your terminal windows or do this in each one to make it refresh:
$ . ~/.bashrc
Installing docker_aliases
will get you some new commands to use in your bash terminal:
Enhanced version of docker ps
which outputs two extra columns:
- IP : The private IP address of the container
- RAM : The amount of RAM the processes inside the container are using
$ dps
CONTAINER ID IMAGE ... NAMES IP RAM
0a3359f50829 23f1a66316b3 ... container-one 172.17.0.139 57 MB
63a1b8ab9fb5 037e0afb42e4 ... container-two 172.17.0.137 490 MB
c9bbee45d255 872fb65cee6d ... container-three 172.17.0.135 1696 MB
Accepts the same command line switches as docker ps
- i.e. dps -a
works.
The nuclear option: Delete all containers & images, remove everything in /var/lib/docker
and restart docker.
NB: Does not prompt for confirmation.
$ docker_wipe
Perform a docker cmd on all docker containers:
$ docker_all start|stop|pause|unpause|<any valid docker cmd>
$ dall start|stop|pause|unpause|<any valid docker cmd>
List the volumes for a given container:
$ docker_vol <container name|id>
List the RAM used by a given container. Used by dps().
$ docker_mem <container name|id>
Return the ID of the container, given the name.
$ docker_id <container_name>
Return the status of the named container.
$ docker_up <container_name>
List the IP address for a given container: Used by dps().
$ docker_ip <container name|id>
Remove any dangling images & exited containers
$ docker_clean
$ dclean
List the links for a given container:
docker_links <container name|id>
dlinks <container name|id>