mirror of
https://github.com/gdiepen/docker-convenience-scripts.git
synced 2025-03-10 03:30:23 +00:00
Merge pull request #1 from mcastellin/remove_untagged
feat: add script to remove untagged images
This commit is contained in:
commit
0063e75796
2 changed files with 19 additions and 0 deletions
|
@ -21,3 +21,11 @@ The script allows me to easily see if there are some data volumes on my disk tha
|
||||||
up a lot of space and are not needed anymore.
|
up a lot of space and are not needed anymore.
|
||||||
|
|
||||||
You can find more details in my blog post [Listing information for all your named/unnamed data volumes](https://www.guidodiepen.nl/2017/04/listing-information-for-all-your-named-unnamed-data-volumes/)
|
You can find more details in my blog post [Listing information for all your named/unnamed data volumes](https://www.guidodiepen.nl/2017/04/listing-information-for-all-your-named-unnamed-data-volumes/)
|
||||||
|
|
||||||
|
## docker_remove_untagged_img.sh
|
||||||
|
|
||||||
|
The purpose for this script is to remove all untagged images from the docker local registry.
|
||||||
|
When building the same docker images multiple times, it is easy to leave a lot of them behind
|
||||||
|
without tags, especially when using `<latest>` tags. These eat up precious space in the
|
||||||
|
hard drive and have little benefit. The convenience script executes the `docker rmi` command for all
|
||||||
|
images with no tags assigned.
|
||||||
|
|
11
docker_remove_untagged_img.sh
Executable file
11
docker_remove_untagged_img.sh
Executable file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ ! "$(docker images | grep "^<none>" | awk '{print $3}')" ]; then
|
||||||
|
echo "No untagged images to remove. Exiting."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Removing all untagged images..."
|
||||||
|
docker rmi $(docker images | grep "^<none>" | awk '{print $3}')
|
||||||
|
|
||||||
|
echo "Done."
|
Loading…
Add table
Reference in a new issue