- Bash/zsh completion
- use Tab to populate command line, narrows down options as you go, fills in container names, ID's, images, volumes. Huge time saver.
- http://blog.alexellis.io/docker-mac-bash-completion/
- https://github.com/docker/docker/blob/master/contrib/completion/bash/docker
- https://docs.docker.com/compose/completion/
- Even without auto complete: you don't need type full container ID's
- just type enough of ID to be unique
- Example:
docker rmi 7c9 2f 5cad
will remove three images
- Name volumes to find/keep easier
- Example:
docker run --name psql -d -p 5432:5432 -v psql:/var/lib/postgresql sameersbn/postgresql
- Then:
docker volume ls
- Example:
- Use ONBUILD Versions for easy development of Node, Ruby, and others
- Always use
docker-compose down
to cleanup properly (networks, containers)- To also remove unnamed containers and volumes:
docker-compose down -v --rmi local
- To also remove unnamed containers and volumes:
- Only removes stopped containers, doesn't delete data volumes, mostly safe
alias drma='docker rm $(docker ps -aq)'
- Remove all images, doesn't remove images in use by containers, mostly safe
alias drmi='docker rmi $(docker images -q -f "dangling=true")'
- Remove all images, doesn't remove images in use by containers, mostly safe
alias drmai='docker rmi $(docker images -q)'
- For Docker Machine users, set docker cli to use the default VM
alias drdefault='eval "$(docker-machine env default)"'
- Execute interactive command in running container
alias drit='docker exec -it'
- Get the IP for eth0 inside the container
alias drip='docker inspect --format="{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}"'
- oh-my-zsh has a add-in, which I use always
- jessfraz has some next level shit as bash functions
- @tcnksm has a good list to start with
- Filtering the image list
- Only list dangling images (built with no name):
docker images --filter "dangling=true"
- Only list dangling images (built with no name):
- Filtering the containers list
- Only list containers that have exited successfully (without error):
docker ps -a --filter 'exited=0'
- Only list containers coming from nginx image:
docker ps --filter ancestor=nginx
- Only list containers that have exited successfully (without error):
- Change the columns shown in docker command, great for TPS Reports
docker images --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}" > images.txt
https://github.com/moby/moby/blob/master/contrib/completion/bash/docker link seems to be dead.