-
Notifications
You must be signed in to change notification settings - Fork 908
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 GitHub? Sign in to your account
Watchtower keeps old default environment variables after updating #1342
Comments
Hi there! 👋🏼 As you're new to this repo, we'd like to suggest that you read our code of conduct as well as our contribution guidelines. Thanks a bunch for opening your first issue! 🙏 |
I don't think this is achievable in a reliable way. How would watchtower know whether the value was put there intentionally or if it came from a default? |
Remove the first list from the second and only the environment variables set by the user are left. Tried it in bash: image_output=$(docker inspect --format "{{range .Config.Env}}{{println .}}{{end}}" pymedusa/medusa:develop)
container_output=$(docker inspect --format "{{range .Config.Env}}{{println .}}{{end}}" medusa)
echo ${image_output[@]} ${container_output[@]} | tr ' ' '\n' | sort | uniq -u Result:
That's exactly what I set. |
I searched a bit and found that there's already code for subtracting the environment variables present: https://github.com/containrrr/watchtower/blob/main/pkg/container/container.go#L254 But it doesn't seem to work for me. |
My question remains however, what happen if the user sets an environment variable to the very same value as the default, and then the image maintainer decides to change that default? Should the value be kept? Removed? |
You can't detect that case, so you have to treat it as "the value was set by the image". |
Which is why I'm hesitant to add this feature. @piksel, what's your take on this? |
Like I said, it's a bugfix for a broken feature, not a new one. |
Just an idea: How about solving this with a label. For example |
That would be great, because for example secrets that are hold solely as an env var in memory have to be kept because the container will not work without them. |
Describe the bug
Many containers have default values for environment variables, which change for each image version. For example, pymedusa/medusa includes the commit hash and branch.
Updating the container via watchtower keeps the old commit hash value. This leads to some wrong information in the app itself.
I think the same is also true for labels.
To Reproduce
Expected behavior
If a container is updated, any environment variable default values should be replaced with the new default values.
Maybe this can be achieved by checking the default environment variables of the old image and removing them from the new
docker run
command.Environment
Platform: Synology
Architecture: amd64
Docker version: 20.10.3
The text was updated successfully, but these errors were encountered: