Last active
October 30, 2018 10:11
-
-
Save teodorescuserban/37818412b612cd3344d3d678fffe4c47 to your computer and use it in GitHub Desktop.
jenkins remove old docker image
This file contains hidden or 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
# SERVICE is the docker-compose service name | |
OLD_IMAGE_ID=$(docker-compose images -q $SERVICE) | |
# CLEAN_UP_OLD_IMAGE is a jenkins boolean param | |
if [ "${CLEAN_UP_OLD_IMAGE}" == "true" ]; then | |
echo -en "\n\nTrying to remove the old image used for ${SERVICE} (ID: ${OLD_IMAGE_ID})...\n" | |
docker rmi ${OLD_IMAGE_ID} 2>/dev/null || echo -en "\nThis image is still in use and has NOT been removed.\n" | |
else | |
echo -en "\nThe old image remains on disk (ID: ${OLD_IMAGE_ID})...\n" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment