diff --git a/cmd/dockerd/daemon.go b/cmd/dockerd/daemon.go index c5f278a391..8565c54787 100644 --- a/cmd/dockerd/daemon.go +++ b/cmd/dockerd/daemon.go @@ -244,6 +244,17 @@ func (cli *daemonCLI) start(ctx context.Context) (err error) { pluginStore := plugin.NewStore() + // Register the CDI driver before the daemon starts, as it might try to restore containers that depend on the CDI driver. + // Note that CDI is not inherently linux-specific, there are some linux-specific assumptions / implementations in the code that + // queries the properties of device on the host as well as performs the injection of device nodes and their access permissions into the OCI spec. + // + // In order to lift this restriction the following would have to be addressed: + // - Support needs to be added to the cdi package for injecting Windows devices: https://tags.cncf.io/container-device-interface/issues/28 + // - The DeviceRequests API must be extended to non-linux platforms. + if runtime.GOOS == "linux" && cli.Config.Features["cdi"] { + daemon.RegisterCDIDriver(cli.Config.CDISpecDirs...) + } + var apiServer apiserver.Server cli.authzMiddleware, err = initMiddlewares(ctx, &apiServer, cli.Config, pluginStore) if err != nil { @@ -262,16 +273,6 @@ func (cli *daemonCLI) start(ctx context.Context) (err error) { return errors.Wrap(err, "failed to validate authorization plugin") } - // Note that CDI is not inherently linux-specific, there are some linux-specific assumptions / implementations in the code that - // queries the properties of device on the host as well as performs the injection of device nodes and their access permissions into the OCI spec. - // - // In order to lift this restriction the following would have to be addressed: - // - Support needs to be added to the cdi package for injecting Windows devices: https://tags.cncf.io/container-device-interface/issues/28 - // - The DeviceRequests API must be extended to non-linux platforms. - if runtime.GOOS == "linux" && cli.Config.Features["cdi"] { - daemon.RegisterCDIDriver(cli.Config.CDISpecDirs...) - } - cli.d = d if err := startMetricsServer(cli.Config.MetricsAddress); err != nil {