1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-02-07 17:10:07 +08:00

fix: 解决容器配置修改后未重启的问题 (#6225)

Refs #6226
This commit is contained in:
ssongliu 2024-08-23 18:24:58 +08:00 committed by GitHub
parent f5f379465f
commit e782f75863
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -198,6 +198,10 @@ func (u *DockerService) UpdateConf(req dto.SettingUpdate) error {
} }
if len(daemonMap) == 0 { if len(daemonMap) == 0 {
_ = os.Remove(constant.DaemonJsonPath) _ = os.Remove(constant.DaemonJsonPath)
stdout, err := cmd.Exec("systemctl restart docker")
if err != nil {
return errors.New(string(stdout))
}
return nil return nil
} }
newJson, err := json.MarshalIndent(daemonMap, "", "\t") newJson, err := json.MarshalIndent(daemonMap, "", "\t")
@ -304,6 +308,10 @@ func (u *DockerService) UpdateIpv6Option(req dto.Ipv6Option) error {
func (u *DockerService) UpdateConfByFile(req dto.DaemonJsonUpdateByFile) error { func (u *DockerService) UpdateConfByFile(req dto.DaemonJsonUpdateByFile) error {
if len(req.File) == 0 { if len(req.File) == 0 {
_ = os.Remove(constant.DaemonJsonPath) _ = os.Remove(constant.DaemonJsonPath)
stdout, err := cmd.Exec("systemctl restart docker")
if err != nil {
return errors.New(string(stdout))
}
return nil return nil
} }
err := createIfNotExistDaemonJsonFile() err := createIfNotExistDaemonJsonFile()