mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-22 05:40:50 +02:00
Merge 51a66ff65e
into 76f9cea516
This commit is contained in:
commit
a17a8806d9
4 changed files with 37 additions and 10 deletions
12
cmd/root.go
12
cmd/root.go
|
@ -117,17 +117,19 @@ func PreRun(cmd *cobra.Command, _ []string) {
|
||||||
reviveStopped, _ := f.GetBool("revive-stopped")
|
reviveStopped, _ := f.GetBool("revive-stopped")
|
||||||
removeVolumes, _ := f.GetBool("remove-volumes")
|
removeVolumes, _ := f.GetBool("remove-volumes")
|
||||||
warnOnHeadPullFailed, _ := f.GetString("warn-on-head-failure")
|
warnOnHeadPullFailed, _ := f.GetString("warn-on-head-failure")
|
||||||
|
disableMemorySwappiness, _ := f.GetBool("disable-memory-swappiness")
|
||||||
|
|
||||||
if monitorOnly && noPull {
|
if monitorOnly && noPull {
|
||||||
log.Warn("Using `WATCHTOWER_NO_PULL` and `WATCHTOWER_MONITOR_ONLY` simultaneously might lead to no action being taken at all. If this is intentional, you may safely ignore this message.")
|
log.Warn("Using `WATCHTOWER_NO_PULL` and `WATCHTOWER_MONITOR_ONLY` simultaneously might lead to no action being taken at all. If this is intentional, you may safely ignore this message.")
|
||||||
}
|
}
|
||||||
|
|
||||||
client = container.NewClient(container.ClientOptions{
|
client = container.NewClient(container.ClientOptions{
|
||||||
IncludeStopped: includeStopped,
|
IncludeStopped: includeStopped,
|
||||||
ReviveStopped: reviveStopped,
|
ReviveStopped: reviveStopped,
|
||||||
RemoveVolumes: removeVolumes,
|
RemoveVolumes: removeVolumes,
|
||||||
IncludeRestarting: includeRestarting,
|
IncludeRestarting: includeRestarting,
|
||||||
WarnOnHeadFailed: container.WarningStrategy(warnOnHeadPullFailed),
|
DisableMemorySwappiness: disableMemorySwappiness,
|
||||||
|
WarnOnHeadFailed: container.WarningStrategy(warnOnHeadPullFailed),
|
||||||
})
|
})
|
||||||
|
|
||||||
notifier = notifications.NewNotifier(cmd)
|
notifier = notifications.NewNotifier(cmd)
|
||||||
|
|
|
@ -465,3 +465,15 @@ Environment Variable: WATCHTOWER_PORCELAIN
|
||||||
Possible values: v1
|
Possible values: v1
|
||||||
Default: -
|
Default: -
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Compatibility with podman (Disable memory swappiness)
|
||||||
|
|
||||||
|
Disable memory swappiness. By default, podman sets the memory-swappiness value to 0 when no memory-swappiness is defined
|
||||||
|
When this flag is specified, watchtower will set the memory-swappiness to nil, fixing a compatibility issue with podman running with crun and cgroupv2
|
||||||
|
|
||||||
|
```text
|
||||||
|
Argument: --disable-memory-swappiness
|
||||||
|
Environment Variable: WATCHTOWER_DISABLE_MEMORY_SWAPPINESS
|
||||||
|
Type: Boolean
|
||||||
|
Default: false
|
||||||
|
```
|
||||||
|
|
|
@ -211,6 +211,12 @@ func RegisterSystemFlags(rootCmd *cobra.Command) {
|
||||||
"",
|
"",
|
||||||
envBool("WATCHTOWER_LABEL_TAKE_PRECEDENCE"),
|
envBool("WATCHTOWER_LABEL_TAKE_PRECEDENCE"),
|
||||||
"Label applied to containers take precedence over arguments")
|
"Label applied to containers take precedence over arguments")
|
||||||
|
|
||||||
|
flags.BoolP(
|
||||||
|
"disable-memory-swappiness",
|
||||||
|
"",
|
||||||
|
envBool("WATCHTOWER_DISABLE_MEMORY_SWAPPINESS"),
|
||||||
|
"Label used for setting memory swappiness as nil when recreating the container, used for compatibility with podman")
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterNotificationFlags that are used by watchtower to send notifications
|
// RegisterNotificationFlags that are used by watchtower to send notifications
|
||||||
|
@ -430,6 +436,7 @@ func SetDefaults() {
|
||||||
viper.SetDefault("WATCHTOWER_NOTIFICATION_SLACK_IDENTIFIER", "watchtower")
|
viper.SetDefault("WATCHTOWER_NOTIFICATION_SLACK_IDENTIFIER", "watchtower")
|
||||||
viper.SetDefault("WATCHTOWER_LOG_LEVEL", "info")
|
viper.SetDefault("WATCHTOWER_LOG_LEVEL", "info")
|
||||||
viper.SetDefault("WATCHTOWER_LOG_FORMAT", "auto")
|
viper.SetDefault("WATCHTOWER_LOG_FORMAT", "auto")
|
||||||
|
viper.SetDefault("WATCHTOWER_DISABLE_MEMORY_SWAPPINESS", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EnvConfig translates the command-line options into environment variables
|
// EnvConfig translates the command-line options into environment variables
|
||||||
|
|
|
@ -57,11 +57,12 @@ func NewClient(opts ClientOptions) Client {
|
||||||
|
|
||||||
// ClientOptions contains the options for how the docker client wrapper should behave
|
// ClientOptions contains the options for how the docker client wrapper should behave
|
||||||
type ClientOptions struct {
|
type ClientOptions struct {
|
||||||
RemoveVolumes bool
|
RemoveVolumes bool
|
||||||
IncludeStopped bool
|
IncludeStopped bool
|
||||||
ReviveStopped bool
|
ReviveStopped bool
|
||||||
IncludeRestarting bool
|
IncludeRestarting bool
|
||||||
WarnOnHeadFailed WarningStrategy
|
DisableMemorySwappiness bool
|
||||||
|
WarnOnHeadFailed WarningStrategy
|
||||||
}
|
}
|
||||||
|
|
||||||
// WarningStrategy is a value determining when to show warnings
|
// WarningStrategy is a value determining when to show warnings
|
||||||
|
@ -251,6 +252,11 @@ func (client dockerClient) StartContainer(c t.Container) (t.ContainerID, error)
|
||||||
hostConfig := c.GetCreateHostConfig()
|
hostConfig := c.GetCreateHostConfig()
|
||||||
networkConfig := client.GetNetworkConfig(c)
|
networkConfig := client.GetNetworkConfig(c)
|
||||||
|
|
||||||
|
// this is a flag set for podman compatibility
|
||||||
|
if client.DisableMemorySwappiness {
|
||||||
|
hostConfig.MemorySwappiness = nil
|
||||||
|
}
|
||||||
|
|
||||||
// simpleNetworkConfig is a networkConfig with only 1 network.
|
// simpleNetworkConfig is a networkConfig with only 1 network.
|
||||||
// see: https://github.com/docker/docker/issues/29265
|
// see: https://github.com/docker/docker/issues/29265
|
||||||
simpleNetworkConfig := func() *network.NetworkingConfig {
|
simpleNetworkConfig := func() *network.NetworkingConfig {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue