feat: add ability to define original image id and image name used in custom images #1978
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR: This PR allows one to add two labels to containers that define which original image was used as the base of the image being run.
The problem
Sometimes it is necessary to build a custom docker image that only slightly changes a base image. For example:
When running this custom image, watchtower cannot figure out that the base nginx image is stale, as it instead only checks if our custom nginx image is stale:
The solution
With this PR, it is possible to add two labels to the container that overwrites the image ID and image name used by watchtower to decide whether the image is stale:
Now, watchtower reports a new nginx version:
Current limitations
Currently automatic updating of the images will break the containers as it will replace the container using images of the original base image. Here it would start
nginx:1.25.5
instead of a custom version of it.Thus, it is necessary to set
monitor-only=1
.Further work
I haven't done: "Tests that verify the code your contributing" and "Updates to the documentation" because I wanted to wait and see if this feature is even desired.
Feel free to reject the PR if the feature does not fit within the scope of this project.