From 6dac897ad44cde44f72da3cd989b89883a13e740 Mon Sep 17 00:00:00 2001 From: "hiroto.toyoda" Date: Mon, 19 Jan 2026 03:36:43 +0900 Subject: [PATCH] daemon: Check system requirements before initialization Move checkSystem() call from inside NewDaemon() to cli.start() to validate system requirements earlier in the startup process. Signed-off-by: hiroto.toyoda --- daemon/command/daemon.go | 5 +++++ daemon/daemon.go | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/daemon/command/daemon.go b/daemon/command/daemon.go index 688ddf085d..46646a5d38 100644 --- a/daemon/command/daemon.go +++ b/daemon/command/daemon.go @@ -114,6 +114,11 @@ func (cli *daemonCLI) start(ctx context.Context) (err error) { debug.Enable() } + // Verify platform-specific requirements before proceeding with daemon initialization + if err := daemon.CheckSystem(); err != nil { + return fmt.Errorf("system requirements not met: %w", err) + } + if rootless.RunningWithRootlessKit() && !cli.Config.IsRootless() { return errors.New("rootless mode needs to be enabled for running with RootlessKit") } diff --git a/daemon/daemon.go b/daemon/daemon.go index 44ebd31810..ccfb9fc91a 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -807,15 +807,15 @@ func (daemon *Daemon) IsSwarmCompatible() error { return daemon.config().IsSwarmCompatible() } +// CheckSystem verifies that the system meets the platform-specific requirements +// for running the Docker daemon. +func CheckSystem() error { + return checkSystem() +} + // 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, authzMiddleware *authorization.Middleware) (_ *Daemon, retErr error) { - // 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) if err != nil { return nil, err