github.com/docker/docker@v299999999.0.0-20200612211812-aaf470eca7b5+incompatible/daemon/reload_unix.go (about)

     1  // +build linux freebsd
     2  
     3  package daemon // import "github.com/docker/docker/daemon"
     4  
     5  import (
     6  	"bytes"
     7  	"fmt"
     8  
     9  	"github.com/docker/docker/api/types"
    10  	"github.com/docker/docker/daemon/config"
    11  )
    12  
    13  // reloadPlatform updates configuration with platform specific options
    14  // and updates the passed attributes
    15  func (daemon *Daemon) reloadPlatform(conf *config.Config, attributes map[string]string) error {
    16  	if err := conf.ValidatePlatformConfig(); err != nil {
    17  		return err
    18  	}
    19  
    20  	if conf.IsValueSet("runtimes") {
    21  		// Always set the default one
    22  		conf.Runtimes[config.StockRuntimeName] = types.Runtime{Path: DefaultRuntimeBinary}
    23  		if err := daemon.initRuntimes(conf.Runtimes); err != nil {
    24  			return err
    25  		}
    26  		daemon.configStore.Runtimes = conf.Runtimes
    27  	}
    28  
    29  	if conf.DefaultRuntime != "" {
    30  		daemon.configStore.DefaultRuntime = conf.DefaultRuntime
    31  	}
    32  
    33  	if conf.IsValueSet("default-shm-size") {
    34  		daemon.configStore.ShmSize = conf.ShmSize
    35  	}
    36  
    37  	if conf.CgroupNamespaceMode != "" {
    38  		daemon.configStore.CgroupNamespaceMode = conf.CgroupNamespaceMode
    39  	}
    40  
    41  	if conf.IpcMode != "" {
    42  		daemon.configStore.IpcMode = conf.IpcMode
    43  	}
    44  
    45  	// Update attributes
    46  	var runtimeList bytes.Buffer
    47  	for name, rt := range daemon.configStore.Runtimes {
    48  		if runtimeList.Len() > 0 {
    49  			runtimeList.WriteRune(' ')
    50  		}
    51  		runtimeList.WriteString(fmt.Sprintf("%s:%s", name, rt))
    52  	}
    53  
    54  	attributes["runtimes"] = runtimeList.String()
    55  	attributes["default-runtime"] = daemon.configStore.DefaultRuntime
    56  	attributes["default-shm-size"] = fmt.Sprintf("%d", daemon.configStore.ShmSize)
    57  	attributes["default-ipc-mode"] = daemon.configStore.IpcMode
    58  	attributes["default-cgroupns-mode"] = daemon.configStore.CgroupNamespaceMode
    59  
    60  	return nil
    61  }