Skip to content

Instantly share code, notes, and snippets.

@uilian
Last active January 16, 2019 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uilian/166a3737457122277f907f7747e0cf99 to your computer and use it in GitHub Desktop.
Save uilian/166a3737457122277f907f7747e0cf99 to your computer and use it in GitHub Desktop.
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