|
@@ -4,6 +4,7 @@ package daemon // import "github.com/docker/docker/daemon"
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
+ "encoding/json"
|
|
|
"fmt"
|
|
|
"os"
|
|
|
"os/exec"
|
|
@@ -43,14 +44,22 @@ func (daemon *Daemon) fillPlatformInfo(ctx context.Context, v *system.Info, sysI
|
|
|
v.CPUSet = sysInfo.Cpuset
|
|
|
v.PidsLimit = sysInfo.PidsLimit
|
|
|
}
|
|
|
- v.Runtimes = make(map[string]system.Runtime)
|
|
|
+ v.Runtimes = make(map[string]system.RuntimeWithStatus)
|
|
|
for n, p := range stockRuntimes() {
|
|
|
- v.Runtimes[n] = system.Runtime{Path: p}
|
|
|
+ v.Runtimes[n] = system.RuntimeWithStatus{
|
|
|
+ Runtime: system.Runtime{
|
|
|
+ Path: p,
|
|
|
+ },
|
|
|
+ Status: daemon.runtimeStatus(ctx, cfg, n),
|
|
|
+ }
|
|
|
}
|
|
|
for n, r := range cfg.Config.Runtimes {
|
|
|
- v.Runtimes[n] = system.Runtime{
|
|
|
- Path: r.Path,
|
|
|
- Args: append([]string(nil), r.Args...),
|
|
|
+ v.Runtimes[n] = system.RuntimeWithStatus{
|
|
|
+ Runtime: system.Runtime{
|
|
|
+ Path: r.Path,
|
|
|
+ Args: append([]string(nil), r.Args...),
|
|
|
+ },
|
|
|
+ Status: daemon.runtimeStatus(ctx, cfg, n),
|
|
|
}
|
|
|
}
|
|
|
v.DefaultRuntime = cfg.Runtimes.Default
|
|
@@ -486,3 +495,24 @@ func populateInitVersion(ctx context.Context, cfg *configStore, v *types.Version
|
|
|
})
|
|
|
return nil
|
|
|
}
|
|
|
+
|
|
|
+// ociRuntimeFeaturesKey is the "well-known" used for including the
|
|
|
+// OCI runtime spec "features" struct.
|
|
|
+//
|
|
|
+// see https://github.com/opencontainers/runtime-spec/blob/main/features.md
|
|
|
+const ociRuntimeFeaturesKey = "org.opencontainers.runtime-spec.features"
|
|
|
+
|
|
|
+func (daemon *Daemon) runtimeStatus(ctx context.Context, cfg *configStore, runtimeName string) map[string]string {
|
|
|
+ m := make(map[string]string)
|
|
|
+ if runtimeName == "" {
|
|
|
+ runtimeName = cfg.Runtimes.Default
|
|
|
+ }
|
|
|
+ if features := cfg.Runtimes.Features(runtimeName); features != nil {
|
|
|
+ if j, err := json.Marshal(features); err == nil {
|
|
|
+ m[ociRuntimeFeaturesKey] = string(j)
|
|
|
+ } else {
|
|
|
+ log.G(ctx).WithFields(log.Fields{"error": err, "runtime": runtimeName}).Warn("Failed to call json.Marshal for the OCI features struct of runtime")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return m
|
|
|
+}
|