Browse code

daemon/config: set default log-driver in config.New

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2026/05/13 00:00:58
Showing 2 changed files
... ...
@@ -56,7 +56,7 @@ func installCommonConfigFlags(conf *config.Config, flags *pflag.FlagSet) {
56 56
 	flags.Var(opts.NewListOptsRef(&conf.DNSSearch, opts.ValidateDNSSearch), "dns-search", "DNS search domains to use")
57 57
 	flags.Var(dopts.NewNamedIPListOptsRef("host-gateway-ips", &conf.HostGatewayIPs), "host-gateway-ip", "IP addresses that the special 'host-gateway' string in --add-host resolves to. Defaults to the IP addresses of the default bridge")
58 58
 	flags.Var(opts.NewNamedListOptsRef("labels", &conf.Labels, opts.ValidateLabel), "label", "Set key=value labels to the daemon")
59
-	flags.StringVar(&conf.LogConfig.Type, "log-driver", "json-file", "Default driver for container logs")
59
+	flags.StringVar(&conf.LogConfig.Type, "log-driver", conf.LogConfig.Type, "Default driver for container logs")
60 60
 	flags.Var(opts.NewNamedMapOpts("log-opts", conf.LogConfig.Config, nil), "log-opt", "Default log driver options for containers")
61 61
 
62 62
 	flags.IntVar(&conf.MaxConcurrentDownloads, "max-concurrent-downloads", conf.MaxConcurrentDownloads, "Set the max concurrent downloads")
... ...
@@ -44,6 +44,8 @@ const (
44 44
 	DefaultNetworkMtu = 1500
45 45
 	// DisableNetworkBridge is the default value of the option to disable network bridge
46 46
 	DisableNetworkBridge = "none"
47
+	// DefaultLogDriver is the default log-driver.
48
+	DefaultLogDriver = "json-file"
47 49
 	// DefaultShutdownTimeout is the default shutdown timeout (in seconds) for
48 50
 	// the daemon for containers to stop when it is shutting down.
49 51
 	DefaultShutdownTimeout = 15
... ...
@@ -336,6 +338,7 @@ func New() (*Config, error) {
336 336
 		CommonConfig: CommonConfig{
337 337
 			ShutdownTimeout: DefaultShutdownTimeout,
338 338
 			LogConfig: LogConfig{
339
+				Type:   DefaultLogDriver,
339 340
 				Config: make(map[string]string),
340 341
 			},
341 342
 			DaemonLogConfig: DaemonLogConfig{