-
Notifications
You must be signed in to change notification settings - Fork 885
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 hooks not working #1004
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! 🙏 |
Already read it and posted the bug above |
Look at the examples in the docs for examples of how to use the hooks: You are currently telling watchtower to only check the container "test" and run any lifecycle-hooks on it before/after checking/updating it. |
I think you are referring to #793, no? That has been merged, but it's not released yet. |
ok thanks I am now creating shell script inside the container and running
it now
Will update in few mins
…On Tue, Jun 29, 2021 at 3:11 PM nils måsén ***@***.***> wrote:
I am pretty sure the latest watchtower build here
https://github.com/containrrr/watchtower supports this skipping update
feature
I think you are referring to #793
<#793>, no? That has been
merged, but it's not released yet.
You can use containrrr/watchtower:latest-dev to try it out!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1004 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AT3CT6BDGI55NAQ2SCGGVJTTVGINDANCNFSM47OHL4NA>
.
|
I assume with latest-dev if the label pre update check fails due to exit
code other than 0 , the watchtower wont update and will retry after set
interval.
Correct
…On Tue, Jun 29, 2021 at 3:11 PM nils måsén ***@***.***> wrote:
I am pretty sure the latest watchtower build here
https://github.com/containrrr/watchtower supports this skipping update
feature
I think you are referring to #793
<#793>, no? That has been
merged, but it's not released yet.
You can use containrrr/watchtower:latest-dev to try it out!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1004 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AT3CT6BDGI55NAQ2SCGGVJTTVGINDANCNFSM47OHL4NA>
.
|
@piksel can you please let me know how to create that pre update scrupt inside container. |
Can you please share the complete commands.I am confused |
I am not sure what you are trying to do, but to run a container that will have it's script executed at the start of every update-session, you can use the following:
where Then run watchtower(-dev) with lifecycle hooks enabled:
|
i wil check thanks
…On Tue, Jun 29, 2021 at 4:10 PM nils måsén ***@***.***> wrote:
I am not sure what you are trying to do, but to run a container that will
have it's script executed at the start of every update-session, you can use
the following:
docker run -d \
--label=com.centurylinklabs.watchtower.lifecycle.pre-check="/dump-data.sh" \
--name validator \
your-validator/image:latest
where your-validator/image contains the /dump-data.sh script you want to
run
Then run watchtower(-dev) with lifecycle hooks enabled:
docker run -d \
--name watchtower \
-v /var/run/docker.sock:/var/run/docker.sock \
containrrr/watchtower-dev \
--debug \
--interval 10 --enable-lifecycle-hooks \
validator
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1004 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AT3CT6GEB7U63PLCPKHXO5TTVGPKRANCNFSM47OHL4NA>
.
|
Basicay i want to update my validator image based on the below condition I am wondering I can create dump-data.sh script and add to validator container. I assume the above logic will work |
I am using above commands but cannot see any labels present when doing inspect This is the docker for validator please advise |
you are putting the labels on the container, not the image:
|
|
This is my logs with
You should have something similar. |
Can u share the complete command you are running |
Looking at the source, it's only the
instead. I'm using this for the
And this for watchtower:
Result in log:
Note that since I typed /usr/bin/false instead of /bin/false the exit code is 127 instead of 1, but it the outcome is the same |
Hello, Is it possible to locate the "dump-data.sh" script in "/root". For example: |
Sure. I used |
Got it, could I use "exit 127" to prevent watchtower from updating like this: |
yeah. any other exit code (except 0) will also cancel the update, but it will be a failure and logged (and notified) as an error. |
Thanks for the help! |
The documentation probably needs an update/clarification
|
Yeah. The published documentation is for
Just to clarify, it does use the docker API, but it explicitly adds the watchtower/pkg/container/client.go Lines 366 to 370 in 7221704
But it does this to mimic what the docker client does when using docker exec .
|
I always through it was baked into the docker API and client, cool. Though isn't the default actually Would you take a PR to make it configurable? Not every container I have has |
Like But yeah, I think so. Since this could be different per container (some contain no /bin/sh, some are scripts that need to be interpreted). Perhaps it could be done by prefixing the command with |
I can not reproduce it @piksel . In the documentation it says:
And I constat this behavior:
So I do not have the same behavior as you have @piksel. Nevertheless, I did see the check in the source code of the watchtower application: if params.LifecycleHooks {
if err := lifecycle.ExecutePreUpdateCommand(client, container); err != nil {
log.Error(err)
log.Info("Skipping container as the pre-update command failed")
return err
}
} Ref: https://github.com/containrrr/watchtower/blob/v1.3.0/internal/actions/update.go My configuration of watchtower is the following:
|
Update:I digged in the code. I understand that a new ExTempFail will be introduced and the value of the error code needed will be 75. |
Yeah, this has not been released yet and is only available for testing in |
Ok thanks for your fast response. I will be using latest-dev until then. |
Hi
I am using pre update hooks in watchtower but the below commands does not even trigger the shell script.
Basically i want to skip update based on shell script
Also this env variable set
WATCHTOWER_LIFECYCLE_HOOKS
to truePleae help a bit urgent
I am pretty sure the latest watchtower build here https://github.com/containrrr/watchtower supports this skipping update feature
Logs :
The text was updated successfully, but these errors were encountered: