github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/cmd/dockerd/config_common_unix.go (about)

     1  // +build linux freebsd
     2  
     3  package main
     4  
     5  import (
     6  	"path/filepath"
     7  
     8  	"github.com/demonoid81/moby/api/types"
     9  	"github.com/demonoid81/moby/daemon/config"
    10  	"github.com/demonoid81/moby/opts"
    11  	"github.com/demonoid81/moby/pkg/homedir"
    12  	"github.com/spf13/pflag"
    13  )
    14  
    15  func getDefaultPidFile() (string, error) {
    16  	if !honorXDG {
    17  		return "/var/run/docker.pid", nil
    18  	}
    19  	runtimeDir, err := homedir.GetRuntimeDir()
    20  	if err != nil {
    21  		return "", err
    22  	}
    23  	return filepath.Join(runtimeDir, "docker.pid"), nil
    24  }
    25  
    26  func getDefaultDataRoot() (string, error) {
    27  	if !honorXDG {
    28  		return "/var/lib/docker", nil
    29  	}
    30  	dataHome, err := homedir.GetDataHome()
    31  	if err != nil {
    32  		return "", err
    33  	}
    34  	return filepath.Join(dataHome, "docker"), nil
    35  }
    36  
    37  func getDefaultExecRoot() (string, error) {
    38  	if !honorXDG {
    39  		return "/var/run/docker", nil
    40  	}
    41  	runtimeDir, err := homedir.GetRuntimeDir()
    42  	if err != nil {
    43  		return "", err
    44  	}
    45  	return filepath.Join(runtimeDir, "docker"), nil
    46  }
    47  
    48  // installUnixConfigFlags adds command-line options to the top-level flag parser for
    49  // the current process that are common across Unix platforms.
    50  func installUnixConfigFlags(conf *config.Config, flags *pflag.FlagSet) {
    51  	conf.Runtimes = make(map[string]types.Runtime)
    52  
    53  	flags.StringVarP(&conf.SocketGroup, "group", "G", "docker", "Group for the unix socket")
    54  	flags.StringVar(&conf.BridgeConfig.IP, "bip", "", "Specify network bridge IP")
    55  	flags.StringVarP(&conf.BridgeConfig.Iface, "bridge", "b", "", "Attach containers to a network bridge")
    56  	flags.StringVar(&conf.BridgeConfig.FixedCIDR, "fixed-cidr", "", "IPv4 subnet for fixed IPs")
    57  	flags.Var(opts.NewIPOpt(&conf.BridgeConfig.DefaultGatewayIPv4, ""), "default-gateway", "Container default gateway IPv4 address")
    58  	flags.Var(opts.NewIPOpt(&conf.BridgeConfig.DefaultGatewayIPv6, ""), "default-gateway-v6", "Container default gateway IPv6 address")
    59  	flags.BoolVar(&conf.BridgeConfig.InterContainerCommunication, "icc", true, "Enable inter-container communication")
    60  	flags.Var(opts.NewIPOpt(&conf.BridgeConfig.DefaultIP, "0.0.0.0"), "ip", "Default IP when binding container ports")
    61  	flags.Var(opts.NewNamedRuntimeOpt("runtimes", &conf.Runtimes, config.StockRuntimeName), "add-runtime", "Register an additional OCI compatible runtime")
    62  	flags.StringVar(&conf.DefaultRuntime, "default-runtime", config.StockRuntimeName, "Default OCI runtime for containers")
    63  
    64  }