containrrr / watchtower

A process for automating Docker container base image updates.
https://containrrr.dev/watchtower/
Apache License 2.0
19.37k stars 856 forks source link

Failing pre-update hook because of crashed/stopped container results in not updating the container #1423

Open koraykoska opened 2 years ago

koraykoska commented 2 years ago

Describe the bug

There is a discrepancy between the documentation and the actual behaviour. According to the documentation:

DO NOTE: If the container is not running then lifecycle hooks can not run and therefore the update is executed without running any lifecycle hooks.

In reality, watchtower does not update in those cases and reports that the pre-update hook failed so the update won't be applied.

Steps to reproduce

  1. Run watchtower with the following: --interval 30 --cleanup --label-enable --rolling-restart --enable-lifecycle-hooks
  2. Add the label com.centurylinklabs.watchtower.lifecycle.pre-update to a watchtower enabled service
  3. Stop the container or put it into a crashing state
  4. Update the image
  5. Check the logs of watchtower
  6. Watchtower skips the update

Expected behavior

Watchtower should update stopped or crashing services as well, even with a pre-update hook. This would be in line with the documentation. Also, there would be no other way to update crashing services (other than manually) in those cases.

Screenshots

No response

Environment

Your logs

n/a

Additional context

No response

github-actions[bot] commented 2 years ago

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! 🙏

piksel commented 2 years ago

You need to supply --include-stopped (and maybe --include-restarting) for watchtower to check containers that are in those states.