github.com/toplink-cn/moby@v0.0.0-20240305205811-460b4aebdf81/daemon/reload_unix.go (about) 1 //go:build linux || freebsd 2 3 package daemon // import "github.com/docker/docker/daemon" 4 5 import ( 6 "bytes" 7 "strconv" 8 9 "github.com/docker/docker/daemon/config" 10 ) 11 12 // reloadPlatform updates configuration with platform specific options 13 // and updates the passed attributes 14 func (daemon *Daemon) reloadPlatform(txn *reloadTxn, newCfg *configStore, conf *config.Config, attributes map[string]string) error { 15 if conf.DefaultRuntime != "" { 16 newCfg.DefaultRuntime = conf.DefaultRuntime 17 } 18 if conf.IsValueSet("runtimes") { 19 newCfg.Config.Runtimes = conf.Runtimes 20 } 21 var err error 22 newCfg.Runtimes, err = setupRuntimes(&newCfg.Config) 23 if err != nil { 24 return err 25 } 26 27 if conf.IsValueSet("default-shm-size") { 28 newCfg.ShmSize = conf.ShmSize 29 } 30 31 if conf.CgroupNamespaceMode != "" { 32 newCfg.CgroupNamespaceMode = conf.CgroupNamespaceMode 33 } 34 35 if conf.IpcMode != "" { 36 newCfg.IpcMode = conf.IpcMode 37 } 38 39 // Update attributes 40 var runtimeList bytes.Buffer 41 for name, rt := range newCfg.Config.Runtimes { 42 if runtimeList.Len() > 0 { 43 runtimeList.WriteRune(' ') 44 } 45 runtimeList.WriteString(name + ":" + rt.Path) 46 } 47 48 attributes["runtimes"] = runtimeList.String() 49 attributes["default-runtime"] = newCfg.DefaultRuntime 50 attributes["default-shm-size"] = strconv.FormatInt(int64(newCfg.ShmSize), 10) 51 attributes["default-ipc-mode"] = newCfg.IpcMode 52 attributes["default-cgroupns-mode"] = newCfg.CgroupNamespaceMode 53 return nil 54 }