2021-08-23 13:14:53 +00:00
|
|
|
//go:build linux || freebsd
|
2018-01-15 15:18:22 +00:00
|
|
|
|
2018-02-05 21:05:59 +00:00
|
|
|
package daemon // import "github.com/docker/docker/daemon"
|
2018-01-15 15:18:22 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
2022-10-05 14:28:35 +00:00
|
|
|
"strconv"
|
2018-01-15 15:18:22 +00:00
|
|
|
|
|
|
|
"github.com/docker/docker/daemon/config"
|
|
|
|
)
|
|
|
|
|
|
|
|
// reloadPlatform updates configuration with platform specific options
|
|
|
|
// and updates the passed attributes
|
2022-08-17 21:13:49 +00:00
|
|
|
func (daemon *Daemon) reloadPlatform(txn *reloadTxn, newCfg, conf *config.Config, attributes map[string]string) error {
|
|
|
|
if conf.DefaultRuntime != "" {
|
|
|
|
newCfg.DefaultRuntime = conf.DefaultRuntime
|
|
|
|
}
|
2018-01-15 15:18:22 +00:00
|
|
|
if conf.IsValueSet("runtimes") {
|
2022-08-17 21:13:49 +00:00
|
|
|
newCfg.Runtimes = conf.Runtimes
|
|
|
|
txn.OnCommit(func() error { return daemon.initRuntimes(newCfg) })
|
2018-01-15 15:18:22 +00:00
|
|
|
}
|
2022-08-17 21:13:49 +00:00
|
|
|
configureRuntimes(newCfg)
|
2018-01-15 15:18:22 +00:00
|
|
|
|
2022-08-17 21:13:49 +00:00
|
|
|
if conf.IsValueSet("default-shm-size") {
|
|
|
|
newCfg.ShmSize = conf.ShmSize
|
2018-01-15 15:18:22 +00:00
|
|
|
}
|
|
|
|
|
2022-08-17 21:13:49 +00:00
|
|
|
if conf.CgroupNamespaceMode != "" {
|
|
|
|
newCfg.CgroupNamespaceMode = conf.CgroupNamespaceMode
|
|
|
|
}
|
2018-01-15 15:18:22 +00:00
|
|
|
|
2022-08-17 21:13:49 +00:00
|
|
|
if conf.IpcMode != "" {
|
|
|
|
newCfg.IpcMode = conf.IpcMode
|
|
|
|
}
|
2018-01-15 15:18:22 +00:00
|
|
|
|
2022-08-17 21:13:49 +00:00
|
|
|
// Update attributes
|
|
|
|
var runtimeList bytes.Buffer
|
|
|
|
for name, rt := range newCfg.Runtimes {
|
|
|
|
if runtimeList.Len() > 0 {
|
|
|
|
runtimeList.WriteRune(' ')
|
2022-08-17 17:33:21 +00:00
|
|
|
}
|
2022-08-17 21:13:49 +00:00
|
|
|
runtimeList.WriteString(name + ":" + rt.Path)
|
|
|
|
}
|
2018-01-15 15:18:22 +00:00
|
|
|
|
2022-08-17 21:13:49 +00:00
|
|
|
attributes["runtimes"] = runtimeList.String()
|
|
|
|
attributes["default-runtime"] = newCfg.DefaultRuntime
|
|
|
|
attributes["default-shm-size"] = strconv.FormatInt(int64(newCfg.ShmSize), 10)
|
|
|
|
attributes["default-ipc-mode"] = newCfg.IpcMode
|
|
|
|
attributes["default-cgroupns-mode"] = newCfg.CgroupNamespaceMode
|
|
|
|
return nil
|
2018-01-15 15:18:22 +00:00
|
|
|
}
|