Skip to content

Instantly share code, notes, and snippets.

@sneycampos
Created April 12, 2023 12:05
Show Gist options
  • Save sneycampos/a993bf84dacd544b4c98b078976b3776 to your computer and use it in GitHub Desktop.
Save sneycampos/a993bf84dacd544b4c98b078976b3776 to your computer and use it in GitHub Desktop.
docker images commands

pegar id da imagem

docker images -q ubuntu:latest

pega id das últimas imagens antes da latest (não inclui a última antes da latest, para fins de backup)

docker images -q --filter "before=ubuntu:latest" --format "{{.ID}}" | awk 'NR>1'

remove todas as imagens antigas, retornadas do ultimo comando

docker rmi $(docker images -q --filter "before=ubuntu:latest" --format "{{.ID}}" | awk 'NR>1')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment