-
Notifications
You must be signed in to change notification settings - Fork 32
Added the prune of docker images when uninstall #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHu 10000 b? Sign in to your account
Conversation
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for implementing this feature 🙂
Left a minor comment for discussion.
start-local.sh
Outdated
|
||
cat >> uninstall.sh <<- EOM | ||
if ask_confirmation; then | ||
docker rmi docker.elastic.co/elasticsearch/elasticsearch:${es_version} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some thoughts regarding a potential unhappy path: If the user has any other container that still actively uses the image, this command will fail.
I can imagine different strategies:
- This should be a rare case, let's not do anything. The user might have to prune the image manually for the
kibana
image, since the script will exit early at this point. - Change to
docker rmi ... || true
to allow the script to continue and try to at least prune thekibana
image (if that's not in use as well). - Proactively check, if the image is still in use before attempting to remove it (e.g.
if [ -n "$(docker ps -a --filter ancestor=docker.elastic.co/elasticsearch/elasticsearch:${es_version} --format '{{.ID}}')" ]; then
)
Personally I would go with the 2. approach since this one:
- Makes the best possible effort to remove all images, even if the removal of one image fails
- It's simple
- No additional custom logic in
start-local.sh
- Standard Docker error message on failure
- No additional custom logic in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think 2 or 3 are valid options. Let me try with 3, I like the idea of checking before and if the image is already in use in other services I can even skip the question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good!
@flobernd I actually proposed a different approach. I check the execution of each if docker rmi "docker.elastic.co/elastic...:${es_version}" >/dev/null 2>&1; then
echo "Image docker.elastic.co/elastic...:${es_version} removed successfully"
else
echo "Failed to remove image docker.elastic.co/elastic...:${es_version}. It might be in use."
fi In this way I don't need to change the execution flow and I manage all the use cases. |
This PR implements the #56 proposal. It adds this questions when running
uninstall.sh
script:If confirm is
yes
the script execute the following commands:The docker disk images of Elasticsearch and Kibana 9.0.2 is about 2.6 GB.