diff --git a/cmd/dockerd/config.go b/cmd/dockerd/config.go index 0f1dff4b8e..20cd999e9e 100644 --- a/cmd/dockerd/config.go +++ b/cmd/dockerd/config.go @@ -3,20 +3,14 @@ package main import ( "runtime" - "github.com/docker/docker/daemon" "github.com/docker/docker/daemon/config" "github.com/docker/docker/opts" - "github.com/docker/docker/plugin/executor/containerd" "github.com/docker/docker/registry" "github.com/spf13/pflag" ) -const ( - // defaultShutdownTimeout is the default shutdown timeout for the daemon - defaultShutdownTimeout = 15 - // defaultTrustKeyFile is the default filename for the trust key - defaultTrustKeyFile = "key.json" -) +// defaultTrustKeyFile is the default filename for the trust key +const defaultTrustKeyFile = "key.json" // installCommonConfigFlags adds flags to the pflag.FlagSet to configure the daemon func installCommonConfigFlags(conf *config.Config, flags *pflag.FlagSet) error { @@ -80,7 +74,7 @@ func installCommonConfigFlags(conf *config.Config, flags *pflag.FlagSet) error { flags.IntVar(&maxConcurrentDownloads, "max-concurrent-downloads", config.DefaultMaxConcurrentDownloads, "Set the max concurrent downloads for each pull") flags.IntVar(&maxConcurrentUploads, "max-concurrent-uploads", config.DefaultMaxConcurrentUploads, "Set the max concurrent uploads for each push") flags.IntVar(&maxDownloadAttempts, "max-download-attempts", config.DefaultDownloadAttempts, "Set the max download attempts for each pull") - flags.IntVar(&conf.ShutdownTimeout, "shutdown-timeout", defaultShutdownTimeout, "Set the default shutdown timeout") + flags.IntVar(&conf.ShutdownTimeout, "shutdown-timeout", config.DefaultShutdownTimeout, "Set the default shutdown timeout") flags.IntVar(&conf.NetworkDiagnosticPort, "network-diagnostic-port", 0, "TCP port number of the network diagnostic server") _ = flags.MarkHidden("network-diagnostic-port") @@ -96,8 +90,8 @@ func installCommonConfigFlags(conf *config.Config, flags *pflag.FlagSet) error { conf.MaxConcurrentUploads = &maxConcurrentUploads conf.MaxDownloadAttempts = &maxDownloadAttempts - flags.StringVar(&conf.ContainerdNamespace, "containerd-namespace", daemon.ContainersNamespace, "Containerd namespace to use") - flags.StringVar(&conf.ContainerdPluginNamespace, "containerd-plugins-namespace", containerd.PluginNamespace, "Containerd namespace to use for plugins") + flags.StringVar(&conf.ContainerdNamespace, "containerd-namespace", config.DefaultContainersNamespace, "Containerd namespace to use") + flags.StringVar(&conf.ContainerdPluginNamespace, "containerd-plugins-namespace", config.DefaultPluginNamespace, "Containerd namespace to use for plugins") flags.StringVar(&conf.DefaultRuntime, "default-runtime", config.StockRuntimeName, "Default OCI runtime for containers") diff --git a/daemon/config/config.go b/daemon/config/config.go index 0f4db6d15c..506fd2898a 100644 --- a/daemon/config/config.go +++ b/daemon/config/config.go @@ -38,11 +38,18 @@ const ( DefaultNetworkMtu = 1500 // DisableNetworkBridge is the default value of the option to disable network bridge DisableNetworkBridge = "none" + // DefaultShutdownTimeout is the default shutdown timeout (in seconds) for + // the daemon for containers to stop when it is shutting down. + DefaultShutdownTimeout = 15 // DefaultInitBinary is the name of the default init binary DefaultInitBinary = "docker-init" // DefaultRuntimeBinary is the default runtime to be used by // containerd if none is specified DefaultRuntimeBinary = "runc" + // DefaultContainersNamespace is the name of the default containerd namespace used for users containers. + DefaultContainersNamespace = "moby" + // DefaultPluginNamespace is the name of the default containerd namespace used for plugins. + DefaultPluginNamespace = "plugins.moby" // LinuxV1RuntimeName is the runtime used to specify the containerd v1 shim with the runc binary // Note this is different than io.containerd.runc.v1 which would be the v1 shim using the v2 shim API. diff --git a/daemon/config/config_linux.go b/daemon/config/config_linux.go index 3523bc6075..27d1c11806 100644 --- a/daemon/config/config_linux.go +++ b/daemon/config/config_linux.go @@ -5,20 +5,20 @@ import ( "net" "github.com/docker/docker/api/types" - containertypes "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/opts" units "github.com/docker/go-units" ) const ( // DefaultIpcMode is default for container's IpcMode, if not set otherwise - DefaultIpcMode = containertypes.IPCModePrivate + DefaultIpcMode = container.IPCModePrivate // DefaultCgroupNamespaceMode is the default mode for containers cgroup namespace when using cgroups v2. - DefaultCgroupNamespaceMode = containertypes.CgroupnsModePrivate + DefaultCgroupNamespaceMode = container.CgroupnsModePrivate // DefaultCgroupV1NamespaceMode is the default mode for containers cgroup namespace when using cgroups v1. - DefaultCgroupV1NamespaceMode = containertypes.CgroupnsModeHost + DefaultCgroupV1NamespaceMode = container.CgroupnsModeHost // StockRuntimeName is the reserved name/alias used to represent the // OCI runtime being shipped with the docker daemon package. @@ -129,7 +129,7 @@ func (conf *Config) IsSwarmCompatible() error { func verifyDefaultIpcMode(mode string) error { const hint = `use "shareable" or "private"` - dm := containertypes.IpcMode(mode) + dm := container.IpcMode(mode) if !dm.Valid() { return fmt.Errorf("default IPC mode setting (%v) is invalid; "+hint, dm) } @@ -140,7 +140,7 @@ func verifyDefaultIpcMode(mode string) error { } func verifyDefaultCgroupNsMode(mode string) error { - cm := containertypes.CgroupnsMode(mode) + cm := container.CgroupnsMode(mode) if !cm.Valid() { return fmt.Errorf(`default cgroup namespace mode (%v) is invalid; use "host" or "private"`, cm) } diff --git a/daemon/daemon.go b/daemon/daemon.go index cdcb6e555b..2a04e33a13 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -69,11 +69,6 @@ import ( "google.golang.org/grpc/credentials/insecure" ) -// ContainersNamespace is the name of the namespace used for users containers -const ( - ContainersNamespace = "moby" -) - var ( errSystemNotSupported = errors.New("the Docker daemon is not supported on this platform") ) diff --git a/plugin/executor/containerd/containerd.go b/plugin/executor/containerd/containerd.go index 8354745990..0daf8afda6 100644 --- a/plugin/executor/containerd/containerd.go +++ b/plugin/executor/containerd/containerd.go @@ -16,9 +16,6 @@ import ( "github.com/sirupsen/logrus" ) -// PluginNamespace is the name used for the plugins namespace -const PluginNamespace = "plugins.moby" - // ExitHandler represents an object that is called when the exit event is received from containerd type ExitHandler interface { HandleExitEvent(id string) error