diff --git a/daemon/daemon.go b/daemon/daemon.go index 8890ec82de..0cd6361f5c 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -710,9 +710,10 @@ func (daemon *Daemon) IsSwarmCompatible() error { // NewDaemon sets up everything for the daemon to be able to service // requests from the webserver. func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.Store) (daemon *Daemon, err error) { - // Verify the platform is supported as a daemon - if !platformSupported { - return nil, errors.New("the Docker daemon is not supported on this platform") + // Verify platform-specific requirements. + // TODO(thaJeztah): this should be called before we try to create the daemon; perhaps together with the config validation. + if err := checkSystem(); err != nil { + return nil, err } registryService, err := registry.NewService(config.ServiceOptions) @@ -736,11 +737,6 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S // Setup the resolv.conf setupResolvConf(config) - // Validate platform-specific requirements - if err := checkSystem(); err != nil { - return nil, err - } - idMapping, err := setupRemappedRoot(config) if err != nil { return nil, err diff --git a/daemon/daemon_unix.go b/daemon/daemon_unix.go index f15dff0af9..20d1409a99 100644 --- a/daemon/daemon_unix.go +++ b/daemon/daemon_unix.go @@ -61,7 +61,6 @@ const ( // See https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/tree/kernel/sched/sched.h?id=8cd9234c64c584432f6992fe944ca9e46ca8ea76#n269 linuxMinCPUShares = 2 linuxMaxCPUShares = 262144 - platformSupported = true // It's not kernel limit, we want this 6M limit to account for overhead during startup, and to supply a reasonable functional container linuxMinMemory = 6291456 // constants for remapped root settings diff --git a/daemon/daemon_unsupported.go b/daemon/daemon_unsupported.go index b154c6c8f5..f66713dbb4 100644 --- a/daemon/daemon_unsupported.go +++ b/daemon/daemon_unsupported.go @@ -4,15 +4,17 @@ package daemon // import "github.com/docker/docker/daemon" import ( - "github.com/docker/docker/daemon/config" + "errors" + "github.com/docker/docker/pkg/sysinfo" ) -const platformSupported = false - -func setupResolvConf(config *config.Config) { +func checkSystem() error { + return errors.New("the Docker daemon is not supported on this platform") } -func getSysInfo(daemon *Daemon) *sysinfo.SysInfo { +func setupResolvConf(_ *interface{}) {} + +func getSysInfo(_ *Daemon) *sysinfo.SysInfo { return sysinfo.New() } diff --git a/daemon/daemon_windows.go b/daemon/daemon_windows.go index ab3428b335..d929da038a 100644 --- a/daemon/daemon_windows.go +++ b/daemon/daemon_windows.go @@ -38,7 +38,6 @@ import ( const ( isWindows = true - platformSupported = true windowsMinCPUShares = 1 windowsMaxCPUShares = 10000 windowsMinCPUPercent = 1