Skip to content

Instantly share code, notes, and snippets.

@slapers
Created October 20, 2016 09:38
Show Gist options
  • Select an option

  • Save slapers/576cdf2dfa53dfd2145c39d3c17e7dcd to your computer and use it in GitHub Desktop.

Select an option

Save slapers/576cdf2dfa53dfd2145c39d3c17e7dcd to your computer and use it in GitHub Desktop.
Cleanup docker images (keeps 10 last versions of each image)
#!/bin/bash
IMAGES=$(docker images --format "{{.Repository}}" | sort | uniq)
for IMAGE in ${IMAGES}; do
OLD=$(docker images ${IMAGE} --format "{{.ID}}" | tail -n +10)
docker rmi ${OLD}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment