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 <hiroto.toyoda@dena.com>
This commit is contained in:
hiroto.toyoda
2026-01-19 03:36:43 +09:00
parent 397c7d65cc
commit 6dac897ad4
2 changed files with 11 additions and 6 deletions

View File

@@ -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")
}

View File

@@ -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