mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-16 23:20:12 +01:00
fix: get the value for post-update command before it is erased
This commit is contained in:
parent
78a375f86e
commit
3df7bbfa32
1 changed files with 8 additions and 1 deletions
|
|
@ -80,11 +80,18 @@ func Update(client container.Client, filter container.Filter, cleanup bool, noRe
|
||||||
}
|
}
|
||||||
|
|
||||||
if !noRestart {
|
if !noRestart {
|
||||||
|
|
||||||
|
// We need to get the command before starting
|
||||||
|
// the container, because `client.StartContainer`
|
||||||
|
// has some side effects that erase the labels
|
||||||
|
// from the container if they are defined in the
|
||||||
|
// the image.
|
||||||
|
postUpdateCommand := container.PostUpdateCommand()
|
||||||
|
|
||||||
if err := client.StartContainer(container); err != nil {
|
if err := client.StartContainer(container); err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
} else {
|
} else {
|
||||||
// Execute the post-update command if it is defined.
|
// Execute the post-update command if it is defined.
|
||||||
postUpdateCommand := container.PostUpdateCommand()
|
|
||||||
if len(postUpdateCommand) > 0 {
|
if len(postUpdateCommand) > 0 {
|
||||||
log.Info("Executing post-update command.")
|
log.Info("Executing post-update command.")
|
||||||
if err := client.ExecuteCommand(container, postUpdateCommand); err != nil {
|
if err := client.ExecuteCommand(container, postUpdateCommand); err != nil {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue