feat: add flag to disable to the memory swappiness

This commit is contained in:
Jiahao Ji Zhou 2025-01-23 11:51:53 +01:00
parent 76f9cea516
commit 51a66ff65e
4 changed files with 37 additions and 10 deletions

View file

@ -57,11 +57,12 @@ func NewClient(opts ClientOptions) Client {
// ClientOptions contains the options for how the docker client wrapper should behave
type ClientOptions struct {
RemoveVolumes bool
IncludeStopped bool
ReviveStopped bool
IncludeRestarting bool
WarnOnHeadFailed WarningStrategy
RemoveVolumes bool
IncludeStopped bool
ReviveStopped bool
IncludeRestarting bool
DisableMemorySwappiness bool
WarnOnHeadFailed WarningStrategy
}
// 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()
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.
// see: https://github.com/docker/docker/issues/29265
simpleNetworkConfig := func() *network.NetworkingConfig {