Skip to content

Check system requirements before initialization#51868

Merged
thaJeztah merged 2 commits intomoby:masterfrom
htoyoda18:refactor/daemon-check-system-before-init
Jan 20, 2026
Merged

Check system requirements before initialization#51868
thaJeztah merged 2 commits intomoby:masterfrom
htoyoda18:refactor/daemon-check-system-before-init

Conversation

@htoyoda18
Copy link
Contributor

@htoyoda18 htoyoda18 commented Jan 18, 2026

- What I did
Resolved the TODO in daemon/daemon.go:814 by moving the checkSystem() call from inside NewDaemon() to an earlier point in the startup process (cli.start() in daemon/command/daemon.go).

This ensures platform-specific system requirements are validated before any daemon initialization begins.

Related to TODO added in 17fb29c.

- How I did it

  1. Exported checkSystem() as a public function CheckSystem() in the daemon package
  2. Added a call to daemon.CheckSystem() in daemon/command/daemon.go's cli.start() function, right after debug mode is enabled and before any resource allocation
  3. Removed the checkSystem() call from inside NewDaemon()
  4. Removed the TODO comment

The changes ensure:

  • System requirements are checked immediately after startup logging is configured
  • On Windows, OS version, vmcompute.dll, and required services are validated before creating directories, registry services, or other resources
  • Cleaner error flow without needing complex defer cleanup on unsupported systems

- How to verify it
Build and run:

# Build should succeed without errors
go build ./daemon/command

# On supported systems, daemon should start normally
sudo dockerd
# or
dockerd --validate

On unsupported systems (e.g., Windows < build 17763), daemon fails immediately with system requirements error before any resource allocation.

- Human readable description for the release notes

The `--validate` flag on dockerd now also verifies system requirements, allowing for system requirements to be checked before starting the daemon.

System requirement errors on Windows are now reported immediately on startup, before resource allocation.

- A picture of a cute animal (not mandatory but encouraged)
image

Move checkSystem() call from inside NewDaemon() to cli.start()
to validate system requirements earlier in the startup process.

Signed-off-by: hiroto.toyoda <[email protected]>
@github-actions github-actions bot added the area/daemon Core Engine label Jan 18, 2026
@thaJeztah thaJeztah added status/2-code-review kind/refactor PR's that refactor, or clean-up code labels Jan 19, 2026
Comment on lines +117 to +120
// Verify platform-specific requirements before proceeding with daemon initialization
if err := daemon.CheckSystem(); err != nil {
return fmt.Errorf("system requirements not met: %w", err)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if we should put it even earlier, e.g. in newDaemonCLI

func newDaemonCLI(opts *daemonOptions) (*daemonCLI, error) {
cfg, err := loadDaemonCliConfig(opts)
if err != nil {
return nil, err
}
tlsConfig, err := newAPIServerTLSConfig(cfg)
if err != nil {
return nil, err
}
return &daemonCLI{

If we would, then errors produced would also show when running dockerd --validate;

cli, err := newDaemonCLI(opts)
if err != nil {
return err
}
if opts.Validate {
// If config wasn't OK we wouldn't have made it this far.
//
// We print this message on STDERR, not STDOUT, to align
// with other tools, such as "nginx -t" or "sshd -t".
cmd.PrintErrln("configuration OK")
return nil
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! You're absolutely right - checking in newDaemonCLI() is better because it also validates system requirements when running dockerd --validate.

b0c8ff7
I've updated the PR to move CheckSystem() to newDaemonCLI() (right after TLS config setup). This way, the validation happens for all commands and provides immediate feedback.

Thank you for the suggestion! 🙏

Move CheckSystem() call to newDaemonCLI() for earlier validation
of platform-specific requirements.

Signed-off-by: hiroto.toyoda <[email protected]>
@htoyoda18 htoyoda18 requested a review from thaJeztah January 19, 2026 18:33
@thaJeztah thaJeztah added kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. impact/changelog labels Jan 20, 2026
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@thaJeztah thaJeztah merged commit 6dcee69 into moby:master Jan 20, 2026
188 of 189 checks passed
@thaJeztah thaJeztah added this to the 29.2.0 milestone Jan 20, 2026
@htoyoda18 htoyoda18 deleted the refactor/daemon-check-system-before-init branch January 20, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/daemon Core Engine impact/changelog kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. kind/refactor PR's that refactor, or clean-up code status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants