:feature: 添加容器内存限制配置,默认值设置为512MB
Some checks failed
BuildImage / build-image (push) Has been cancelled
Some checks failed
BuildImage / build-image (push) Has been cancelled
This commit is contained in:
parent
963ae62367
commit
4ca9c5e2d7
@ -18,6 +18,7 @@ docker:
|
||||
apiVersion: "1.41"
|
||||
imageName: "lxh01/xybotv2:latest"
|
||||
network: "bridge"
|
||||
memory: 123 # 容器内存限制(MB)
|
||||
redis:
|
||||
host: "10.0.0.31"
|
||||
password: "pGhQKwj7DE7FbFL1"
|
||||
|
@ -33,6 +33,7 @@ docker:
|
||||
apiVersion: "1.41"
|
||||
imageName: "lxh01/xybotv2:latest"
|
||||
network: "bridge"
|
||||
memory: 123 # 容器内存限制(MB)
|
||||
redis:
|
||||
host: "10.0.0.31"
|
||||
password: "pGhQKwj7DE7FbFL1"
|
||||
|
@ -17,6 +17,7 @@ type DockerConfig struct {
|
||||
APIVersion string `mapstructure:"apiVersion"` // Docker API版本
|
||||
ImageName string `mapstructure:"imageName"` // 微信机器人Docker镜像名称
|
||||
Network string `mapstructure:"network"` // 容器网络
|
||||
Memory int64 `mapstructure:"memory"` // 内存限制
|
||||
Redis RedisConfig `mapstructure:"redis"` // Redis配置
|
||||
}
|
||||
|
||||
|
@ -100,6 +100,10 @@ func CreateContainer(ctx context.Context, cfg *config.DockerConfig, name string,
|
||||
Name: "unless-stopped",
|
||||
},
|
||||
}
|
||||
if cfg.Memory == 0 {
|
||||
cfg.Memory = 512 // 默认内存限制为512M
|
||||
}
|
||||
hostConfig.Memory = cfg.Memory * 1024 * 1024 // 限制使用内存
|
||||
|
||||
// 设置网络配置
|
||||
networkingConfig := &network.NetworkingConfig{}
|
||||
|
Loading…
x
Reference in New Issue
Block a user