docker info: expose runtime features ("rro" mount mode, etc.)
Fix issue 46580 ```console $ curl -s --unix-socket /var/run/docker.sock http://docker/v1.44/info | jq .Runtimes { "crun": { "path": "/usr/local/bin/crun", "status": { "org.opencontainers.runtime-spec.features": "{\"ociVersionMin\":\"1.0.0\",...}" } }, "io.containerd.runc.v2": { "path": "runc", "status": { "org.opencontainers.runtime-spec.features": "{\"ociVersionMin\":\"1.0.0\",...}" } }, "runc": { "path": "runc", "status": { "org.opencontainers.runtime-spec.features": "{\"ociVersionMin\":\"1.0.0\",...}" } }, "runsc": { "path": "/usr/local/bin/runsc" } } ``` Co-authored-by: Sebastiaan van Stijn <github@gone.nl> Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
parent
bd70d66a62
commit
9e6d012e9c
6 changed files with 71 additions and 6 deletions
|
@ -91,6 +91,12 @@ func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *ht
|
||||||
info.OperatingSystem = "<unknown>"
|
info.OperatingSystem = "<unknown>"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if versions.LessThan(version, "1.44") {
|
||||||
|
for k, rt := range info.Runtimes {
|
||||||
|
// Status field introduced inl API v1.44.
|
||||||
|
info.Runtimes[k] = system.RuntimeWithStatus{Runtime: rt.Runtime}
|
||||||
|
}
|
||||||
|
}
|
||||||
if versions.GreaterThanOrEqualTo(version, "1.42") {
|
if versions.GreaterThanOrEqualTo(version, "1.42") {
|
||||||
info.KernelMemory = false
|
info.KernelMemory = false
|
||||||
}
|
}
|
||||||
|
|
|
@ -5618,6 +5618,28 @@ definitions:
|
||||||
items:
|
items:
|
||||||
type: "string"
|
type: "string"
|
||||||
example: ["--debug", "--systemd-cgroup=false"]
|
example: ["--debug", "--systemd-cgroup=false"]
|
||||||
|
status:
|
||||||
|
description: |
|
||||||
|
Information specific to the runtime.
|
||||||
|
|
||||||
|
While this API specification does not define data provided by runtimes,
|
||||||
|
the following well-known properties may be provided by runtimes:
|
||||||
|
|
||||||
|
`org.opencontainers.runtime-spec.features`: features structure as defined
|
||||||
|
in the [OCI Runtime Specification](https://github.com/opencontainers/runtime-spec/blob/main/features.md),
|
||||||
|
in a JSON string representation.
|
||||||
|
|
||||||
|
<p><br /></p>
|
||||||
|
|
||||||
|
> **Note**: The information returned in this field, including the
|
||||||
|
> formatting of values and labels, should not be considered stable,
|
||||||
|
> and may change without notice.
|
||||||
|
type: "object"
|
||||||
|
x-nullable: true
|
||||||
|
additionalProperties:
|
||||||
|
type: "string"
|
||||||
|
example:
|
||||||
|
"org.opencontainers.runtime-spec.features": "{\"ociVersionMin\":\"1.0.0\",\"ociVersionMax\":\"1.1.0\",\"...\":\"...\"}"
|
||||||
|
|
||||||
Commit:
|
Commit:
|
||||||
description: |
|
description: |
|
||||||
|
|
|
@ -58,7 +58,7 @@ type Info struct {
|
||||||
Labels []string
|
Labels []string
|
||||||
ExperimentalBuild bool
|
ExperimentalBuild bool
|
||||||
ServerVersion string
|
ServerVersion string
|
||||||
Runtimes map[string]Runtime
|
Runtimes map[string]RuntimeWithStatus
|
||||||
DefaultRuntime string
|
DefaultRuntime string
|
||||||
Swarm swarm.Info
|
Swarm swarm.Info
|
||||||
// LiveRestoreEnabled determines whether containers should be kept
|
// LiveRestoreEnabled determines whether containers should be kept
|
||||||
|
|
|
@ -12,3 +12,9 @@ type Runtime struct {
|
||||||
Type string `json:"runtimeType,omitempty"`
|
Type string `json:"runtimeType,omitempty"`
|
||||||
Options map[string]interface{} `json:"options,omitempty"`
|
Options map[string]interface{} `json:"options,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RuntimeWithStatus extends [Runtime] to hold [RuntimeStatus].
|
||||||
|
type RuntimeWithStatus struct {
|
||||||
|
Runtime
|
||||||
|
Status map[string]string `json:"status,omitempty"`
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ package daemon // import "github.com/docker/docker/daemon"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -43,14 +44,22 @@ func (daemon *Daemon) fillPlatformInfo(ctx context.Context, v *system.Info, sysI
|
||||||
v.CPUSet = sysInfo.Cpuset
|
v.CPUSet = sysInfo.Cpuset
|
||||||
v.PidsLimit = sysInfo.PidsLimit
|
v.PidsLimit = sysInfo.PidsLimit
|
||||||
}
|
}
|
||||||
v.Runtimes = make(map[string]system.Runtime)
|
v.Runtimes = make(map[string]system.RuntimeWithStatus)
|
||||||
for n, p := range stockRuntimes() {
|
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 {
|
for n, r := range cfg.Config.Runtimes {
|
||||||
v.Runtimes[n] = system.Runtime{
|
v.Runtimes[n] = system.RuntimeWithStatus{
|
||||||
|
Runtime: system.Runtime{
|
||||||
Path: r.Path,
|
Path: r.Path,
|
||||||
Args: append([]string(nil), r.Args...),
|
Args: append([]string(nil), r.Args...),
|
||||||
|
},
|
||||||
|
Status: daemon.runtimeStatus(ctx, cfg, n),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
v.DefaultRuntime = cfg.Runtimes.Default
|
v.DefaultRuntime = cfg.Runtimes.Default
|
||||||
|
@ -486,3 +495,24 @@ func populateInitVersion(ctx context.Context, cfg *configStore, v *types.Version
|
||||||
})
|
})
|
||||||
return nil
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@ keywords: "API, Docker, rcli, REST, documentation"
|
||||||
requests is now deprecated. You should instead use the field `TaskTemplate.Networks`.
|
requests is now deprecated. You should instead use the field `TaskTemplate.Networks`.
|
||||||
* The `Container` and `ContainerConfig` fields in the `GET /images/{name}/json`
|
* The `Container` and `ContainerConfig` fields in the `GET /images/{name}/json`
|
||||||
response are deprecated and will no longer be included in API v1.45.
|
response are deprecated and will no longer be included in API v1.45.
|
||||||
|
* `GET /info` now includes `status` properties in `Runtimes`.
|
||||||
|
|
||||||
## v1.43 API changes
|
## v1.43 API changes
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue