github.com/Heebron/moby@v0.0.0-20221111184709-6eab4f55faf7/cmd/dockerd/config.go (about) 1 package main 2 3 import ( 4 "github.com/docker/docker/daemon/config" 5 "github.com/docker/docker/opts" 6 "github.com/docker/docker/registry" 7 "github.com/spf13/pflag" 8 ) 9 10 // defaultTrustKeyFile is the default filename for the trust key 11 const defaultTrustKeyFile = "key.json" 12 13 // installCommonConfigFlags adds flags to the pflag.FlagSet to configure the daemon 14 func installCommonConfigFlags(conf *config.Config, flags *pflag.FlagSet) error { 15 var ( 16 allowNonDistributable = opts.NewNamedListOptsRef("allow-nondistributable-artifacts", &conf.AllowNondistributableArtifacts, registry.ValidateIndexName) 17 registryMirrors = opts.NewNamedListOptsRef("registry-mirrors", &conf.Mirrors, registry.ValidateMirror) 18 insecureRegistries = opts.NewNamedListOptsRef("insecure-registries", &conf.InsecureRegistries, registry.ValidateIndexName) 19 ) 20 flags.Var(allowNonDistributable, "allow-nondistributable-artifacts", "Allow push of nondistributable artifacts to registry") 21 flags.Var(registryMirrors, "registry-mirror", "Preferred Docker registry mirror") 22 flags.Var(insecureRegistries, "insecure-registry", "Enable insecure registry communication") 23 24 flags.Var(opts.NewNamedListOptsRef("storage-opts", &conf.GraphOptions, nil), "storage-opt", "Storage driver options") 25 flags.Var(opts.NewNamedListOptsRef("authorization-plugins", &conf.AuthorizationPlugins, nil), "authorization-plugin", "Authorization plugins to load") 26 flags.Var(opts.NewNamedListOptsRef("exec-opts", &conf.ExecOptions, nil), "exec-opt", "Runtime execution options") 27 flags.StringVarP(&conf.Pidfile, "pidfile", "p", conf.Pidfile, "Path to use for daemon PID file") 28 flags.StringVar(&conf.Root, "data-root", conf.Root, "Root directory of persistent Docker state") 29 flags.StringVar(&conf.ExecRoot, "exec-root", conf.ExecRoot, "Root directory for execution state files") 30 flags.StringVar(&conf.ContainerdAddr, "containerd", "", "containerd grpc address") 31 flags.BoolVar(&conf.CriContainerd, "cri-containerd", false, "start containerd with cri") 32 33 flags.IntVar(&conf.Mtu, "mtu", conf.Mtu, "Set the containers network MTU") 34 flags.IntVar(&conf.NetworkControlPlaneMTU, "network-control-plane-mtu", conf.NetworkControlPlaneMTU, "Network Control plane MTU") 35 flags.IntVar(&conf.NetworkDiagnosticPort, "network-diagnostic-port", 0, "TCP port number of the network diagnostic server") 36 _ = flags.MarkHidden("network-diagnostic-port") 37 38 flags.BoolVar(&conf.RawLogs, "raw-logs", false, "Full timestamps without ANSI coloring") 39 flags.Var(opts.NewListOptsRef(&conf.DNS, opts.ValidateIPAddress), "dns", "DNS server to use") 40 flags.Var(opts.NewNamedListOptsRef("dns-opts", &conf.DNSOptions, nil), "dns-opt", "DNS options to use") 41 flags.Var(opts.NewListOptsRef(&conf.DNSSearch, opts.ValidateDNSSearch), "dns-search", "DNS search domains to use") 42 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") 43 flags.Var(opts.NewNamedListOptsRef("labels", &conf.Labels, opts.ValidateLabel), "label", "Set key=value labels to the daemon") 44 flags.StringVar(&conf.LogConfig.Type, "log-driver", "json-file", "Default driver for container logs") 45 flags.Var(opts.NewNamedMapOpts("log-opts", conf.LogConfig.Config, nil), "log-opt", "Default log driver options for containers") 46 47 flags.StringVar(&conf.CorsHeaders, "api-cors-header", "", "Set CORS headers in the Engine API") 48 flags.IntVar(&conf.MaxConcurrentDownloads, "max-concurrent-downloads", conf.MaxConcurrentDownloads, "Set the max concurrent downloads") 49 flags.IntVar(&conf.MaxConcurrentUploads, "max-concurrent-uploads", conf.MaxConcurrentUploads, "Set the max concurrent uploads") 50 flags.IntVar(&conf.MaxDownloadAttempts, "max-download-attempts", conf.MaxDownloadAttempts, "Set the max download attempts for each pull") 51 flags.IntVar(&conf.ShutdownTimeout, "shutdown-timeout", conf.ShutdownTimeout, "Set the default shutdown timeout") 52 53 flags.StringVar(&conf.SwarmDefaultAdvertiseAddr, "swarm-default-advertise-addr", "", "Set default address or interface for swarm advertised address") 54 flags.BoolVar(&conf.Experimental, "experimental", false, "Enable experimental features") 55 flags.StringVar(&conf.MetricsAddress, "metrics-addr", "", "Set default address and port to serve the metrics api on") 56 flags.Var(opts.NewNamedListOptsRef("node-generic-resources", &conf.NodeGenericResources, opts.ValidateSingleGenericResource), "node-generic-resource", "Advertise user-defined resource") 57 58 flags.StringVar(&conf.ContainerdNamespace, "containerd-namespace", conf.ContainerdNamespace, "Containerd namespace to use") 59 flags.StringVar(&conf.ContainerdPluginNamespace, "containerd-plugins-namespace", conf.ContainerdPluginNamespace, "Containerd namespace to use for plugins") 60 flags.StringVar(&conf.DefaultRuntime, "default-runtime", conf.DefaultRuntime, "Default OCI runtime for containers") 61 62 flags.StringVar(&conf.HTTPProxy, "http-proxy", "", "HTTP proxy URL to use for outgoing traffic") 63 flags.StringVar(&conf.HTTPSProxy, "https-proxy", "", "HTTPS proxy URL to use for outgoing traffic") 64 flags.StringVar(&conf.NoProxy, "no-proxy", "", "Comma-separated list of hosts or IP addresses for which the proxy is skipped") 65 66 // Deprecated flags / options 67 68 //nolint:staticcheck // TODO(thaJeztah): remove in next release. 69 flags.StringVarP(&conf.RootDeprecated, "graph", "g", conf.RootDeprecated, "Root of the Docker runtime") 70 _ = flags.MarkDeprecated("graph", "Use --data-root instead") 71 flags.BoolVarP(&conf.AutoRestart, "restart", "r", true, "--restart on the daemon has been deprecated in favor of --restart policies on docker run") 72 _ = flags.MarkDeprecated("restart", "Please use a restart policy on docker run") 73 74 return nil 75 }