Skip to content

Instantly share code, notes, and snippets.

@uilian uilian/docker-commands.md
Last active Jan 16, 2019

Embed
What would you like to do?
More docker commands

Removes all containers returned by condition

docker container rm $(docker container ps -qa --filter "name=example1" --filter "name=example2")

Removes images older than specified 'ImageID' and not tagged

docker image rm $(docker images -q --filter "dangling=true" --filter "before=ImageID")

List all container using specified volume

docker volume ls --format "{{.Name}}" | xargs -I '{}' docker ps -a --filter volume="{}"

List all images created from n months.

docker images --format='{{.CreatedSince}}:{{ .ID}}' |grep month| cut -d ':' -f 2

Lists all layers from all images

docker images -q | xargs -I '{}'  docker inspect "{}" --format "{{println .Id}}{{range .RootFS.Layers}}   {{println .}}{{end}}"

Removes containers that are stopped more than 'XX' hours.

docker container prune --filter until=XXh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.