github.com/rish1988/moby@v25.0.2+incompatible/cmd/dockerd/config.go (about) 1 package main 2 3 import ( 4 "runtime" 5 6 "github.com/docker/docker/daemon/config" 7 "github.com/docker/docker/opts" 8 "github.com/docker/docker/registry" 9 "github.com/spf13/pflag" 10 ) 11 12 // installCommonConfigFlags adds flags to the pflag.FlagSet to configure the daemon 13 func installCommonConfigFlags(conf *config.Config, flags *pflag.FlagSet) error { 14 var ( 15 allowNonDistributable = opts.NewNamedListOptsRef("allow-nondistributable-artifacts", &conf.AllowNondistributableArtifacts, registry.ValidateIndexName) 16 registryMirrors = opts.NewNamedListOptsRef("registry-mirrors", &conf.Mirrors, registry.ValidateMirror) 17 insecureRegistries = opts.NewNamedListOptsRef("insecure-registries", &conf.InsecureRegistries, registry.ValidateIndexName) 18 ) 19 flags.Var(allowNonDistributable, "allow-nondistributable-artifacts", "Allow push of nondistributable artifacts to registry") 20 flags.Var(registryMirrors, "registry-mirror", "Preferred Docker registry mirror") 21 flags.Var(insecureRegistries, "insecure-registry", "Enable insecure registry communication") 22 23 flags.Var(opts.NewNamedListOptsRef("storage-opts", &conf.GraphOptions, nil), "storage-opt", "Storage driver options") 24 flags.Var(opts.NewNamedListOptsRef("authorization-plugins", &conf.AuthorizationPlugins, nil), "authorization-plugin", "Authorization plugins to load") 25 flags.Var(opts.NewNamedListOptsRef("exec-opts", &conf.ExecOptions, nil), "exec-opt", "Runtime execution options") 26 flags.StringVarP(&conf.Pidfile, "pidfile", "p", conf.Pidfile, "Path to use for daemon PID file") 27 flags.StringVar(&conf.Root, "data-root", conf.Root, "Root directory of persistent Docker state") 28 flags.StringVar(&conf.ExecRoot, "exec-root", conf.ExecRoot, "Root directory for execution state files") 29 flags.StringVar(&conf.ContainerdAddr, "containerd", "", "containerd grpc address") 30 flags.BoolVar(&conf.CriContainerd, "cri-containerd", false, "start containerd with cri") 31 32 flags.Var(opts.NewNamedMapMapOpts("default-network-opts", conf.DefaultNetworkOpts, nil), "default-network-opt", "Default network options") 33 flags.IntVar(&conf.MTU, "mtu", conf.MTU, `Set the MTU for the default "bridge" network`) 34 if runtime.GOOS == "windows" { 35 // The mtu option is not used on Windows, but it has been available since 36 // "forever" (and always silently ignored). We hide the flag for now, 37 // to discourage using it (and print a warning if it's set), but not 38 // "hard-deprecating" it, to not break users, and in case it will be 39 // supported on Windows in future. 40 flags.MarkHidden("mtu") 41 } 42 43 flags.IntVar(&conf.NetworkControlPlaneMTU, "network-control-plane-mtu", conf.NetworkControlPlaneMTU, "Network Control plane MTU") 44 flags.IntVar(&conf.NetworkDiagnosticPort, "network-diagnostic-port", 0, "TCP port number of the network diagnostic server") 45 _ = flags.MarkHidden("network-diagnostic-port") 46 47 flags.BoolVar(&conf.RawLogs, "raw-logs", false, "Full timestamps without ANSI coloring") 48 flags.IPSliceVar(&conf.DNS, "dns", conf.DNS, "DNS server to use") 49 flags.Var(opts.NewNamedListOptsRef("dns-opts", &conf.DNSOptions, nil), "dns-opt", "DNS options to use") 50 flags.Var(opts.NewListOptsRef(&conf.DNSSearch, opts.ValidateDNSSearch), "dns-search", "DNS search domains to use") 51 flags.IPVar(&conf.HostGatewayIP, "host-gateway-ip", nil, "IP address that the special 'host-gateway' string in --add-host resolves to. Defaults to the IP address of the default bridge") 52 flags.Var(opts.NewNamedListOptsRef("labels", &conf.Labels, opts.ValidateLabel), "label", "Set key=value labels to the daemon") 53 flags.StringVar(&conf.LogConfig.Type, "log-driver", "json-file", "Default driver for container logs") 54 flags.Var(opts.NewNamedMapOpts("log-opts", conf.LogConfig.Config, nil), "log-opt", "Default log driver options for containers") 55 56 flags.StringVar(&conf.CorsHeaders, "api-cors-header", "", "Set CORS headers in the Engine API") 57 flags.IntVar(&conf.MaxConcurrentDownloads, "max-concurrent-downloads", conf.MaxConcurrentDownloads, "Set the max concurrent downloads") 58 flags.IntVar(&conf.MaxConcurrentUploads, "max-concurrent-uploads", conf.MaxConcurrentUploads, "Set the max concurrent uploads") 59 flags.IntVar(&conf.MaxDownloadAttempts, "max-download-attempts", conf.MaxDownloadAttempts, "Set the max download attempts for each pull") 60 flags.IntVar(&conf.ShutdownTimeout, "shutdown-timeout", conf.ShutdownTimeout, "Set the default shutdown timeout") 61 62 flags.StringVar(&conf.SwarmDefaultAdvertiseAddr, "swarm-default-advertise-addr", "", "Set default address or interface for swarm advertised address") 63 flags.BoolVar(&conf.Experimental, "experimental", false, "Enable experimental features") 64 flags.StringVar(&conf.MetricsAddress, "metrics-addr", "", "Set default address and port to serve the metrics api on") 65 flags.Var(opts.NewNamedListOptsRef("node-generic-resources", &conf.NodeGenericResources, opts.ValidateSingleGenericResource), "node-generic-resource", "Advertise user-defined resource") 66 67 flags.StringVar(&conf.ContainerdNamespace, "containerd-namespace", conf.ContainerdNamespace, "Containerd namespace to use") 68 flags.StringVar(&conf.ContainerdPluginNamespace, "containerd-plugins-namespace", conf.ContainerdPluginNamespace, "Containerd namespace to use for plugins") 69 flags.StringVar(&conf.DefaultRuntime, "default-runtime", conf.DefaultRuntime, "Default OCI runtime for containers") 70 71 flags.StringVar(&conf.HTTPProxy, "http-proxy", "", "HTTP proxy URL to use for outgoing traffic") 72 flags.StringVar(&conf.HTTPSProxy, "https-proxy", "", "HTTPS proxy URL to use for outgoing traffic") 73 flags.StringVar(&conf.NoProxy, "no-proxy", "", "Comma-separated list of hosts or IP addresses for which the proxy is skipped") 74 75 flags.Var(opts.NewNamedListOptsRef("cdi-spec-dirs", &conf.CDISpecDirs, nil), "cdi-spec-dir", "CDI specification directories to use") 76 77 // Deprecated flags / options 78 79 flags.BoolVarP(&conf.AutoRestart, "restart", "r", true, "--restart on the daemon has been deprecated in favor of --restart policies on docker run") 80 _ = flags.MarkDeprecated("restart", "Please use a restart policy on docker run") 81 82 return nil 83 }