github.com/kaisenlinux/docker@v0.0.0-20230510090727-ea55db55fac7/engine/daemon/config/config_common_unix.go (about)

     1  //go:build linux || freebsd
     2  // +build linux freebsd
     3  
     4  package config // import "github.com/docker/docker/daemon/config"
     5  
     6  import (
     7  	"net"
     8  
     9  	"github.com/docker/docker/api/types"
    10  )
    11  
    12  // CommonUnixConfig defines configuration of a docker daemon that is
    13  // common across Unix platforms.
    14  type CommonUnixConfig struct {
    15  	Runtimes          map[string]types.Runtime `json:"runtimes,omitempty"`
    16  	DefaultRuntime    string                   `json:"default-runtime,omitempty"`
    17  	DefaultInitBinary string                   `json:"default-init,omitempty"`
    18  }
    19  
    20  type commonUnixBridgeConfig struct {
    21  	DefaultIP                   net.IP `json:"ip,omitempty"`
    22  	IP                          string `json:"bip,omitempty"`
    23  	DefaultGatewayIPv4          net.IP `json:"default-gateway,omitempty"`
    24  	DefaultGatewayIPv6          net.IP `json:"default-gateway-v6,omitempty"`
    25  	InterContainerCommunication bool   `json:"icc,omitempty"`
    26  }
    27  
    28  // GetRuntime returns the runtime path and arguments for a given
    29  // runtime name
    30  func (conf *Config) GetRuntime(name string) *types.Runtime {
    31  	conf.Lock()
    32  	defer conf.Unlock()
    33  	if rt, ok := conf.Runtimes[name]; ok {
    34  		return &rt
    35  	}
    36  	return nil
    37  }
    38  
    39  // GetDefaultRuntimeName returns the current default runtime
    40  func (conf *Config) GetDefaultRuntimeName() string {
    41  	conf.Lock()
    42  	rt := conf.DefaultRuntime
    43  	conf.Unlock()
    44  
    45  	return rt
    46  }
    47  
    48  // GetAllRuntimes returns a copy of the runtimes map
    49  func (conf *Config) GetAllRuntimes() map[string]types.Runtime {
    50  	conf.Lock()
    51  	rts := conf.Runtimes
    52  	conf.Unlock()
    53  	return rts
    54  }
    55  
    56  // GetExecRoot returns the user configured Exec-root
    57  func (conf *Config) GetExecRoot() string {
    58  	return conf.ExecRoot
    59  }
    60  
    61  // GetInitPath returns the configured docker-init path
    62  func (conf *Config) GetInitPath() string {
    63  	conf.Lock()
    64  	defer conf.Unlock()
    65  	if conf.InitPath != "" {
    66  		return conf.InitPath
    67  	}
    68  	if conf.DefaultInitBinary != "" {
    69  		return conf.DefaultInitBinary
    70  	}
    71  	return DefaultInitBinary
    72  }
    73  
    74  // GetResolvConf returns the appropriate resolv.conf
    75  // Check setupResolvConf on how this is selected
    76  func (conf *Config) GetResolvConf() string {
    77  	return conf.ResolvConf
    78  }