Created
December 31, 2019 06:01
-
-
Save Hypro999/58c6522adf0eb2fe4bbe1b9deadf8bd3 to your computer and use it in GitHub Desktop.
A simple, naive bash script to clear out intermediate docker images after building one.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Inspired by nnsense's answer at https://forums.docker.com/t/how-to-remove-none-images-after-building/7050/16 | |
if [ $# -ne 1 ]; then | |
echo "You must enter a single valid image id or name." | |
else | |
# Assume that the image id/name is actually valid. | |
docker save --output /tmp/image.tar $1 | |
docker image rm $1 | |
docker image prune # Just an extra cleanup step while we're at it. | |
docker load --input /tmp/image.tar | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment