Skip to content

feat: show RootlessKit version in nerdctl version output#4971

Merged
ChengyuZhu6 merged 1 commit into
containerd:mainfrom
amarkdotdev:feat/version-rootlesskit
Jun 22, 2026
Merged

feat: show RootlessKit version in nerdctl version output#4971
ChengyuZhu6 merged 1 commit into
containerd:mainfrom
amarkdotdev:feat/version-rootlesskit

Conversation

@amarkdotdev

Copy link
Copy Markdown
Contributor

Description

When running in rootless mode, nerdctl version now includes the RootlessKit version as a server component, matching how docker version displays it.

Before:

Server:
 containerd:
  Version:	v2.1.0
 runc:
  Version:	1.2.6

After (rootless mode):

Server:
 containerd:
  Version:	v2.1.0
 runc:
  Version:	1.2.6
 rootlesskit:
  Version:	2.3.1

The rootlesskit component is only shown when rootlessutil.IsRootless() is true. If rootlesskit is not found on PATH or its output cannot be parsed, a warning is logged and the component appears without a version string (same pattern as runc and buildctl).

Changes

  • pkg/infoutil/infoutil.go: added rootlessKitVersion() and parseRootlessKitVersion() functions, appended to ServerVersion.Components when rootless
  • pkg/infoutil/infoutil_test.go: added TestParseRootlessKitVersion covering normal output, dev versions, and invalid input

Testing

  • go build ./pkg/infoutil/... passes
  • go vet ./pkg/infoutil/... passes
  • go test ./pkg/infoutil/... passes (including the new parse test)

Fixes #4936

@amarkdotdev amarkdotdev force-pushed the feat/version-rootlesskit branch from 98761a9 to 02bf394 Compare June 18, 2026 14:25
Comment thread pkg/infoutil/infoutil.go Outdated
return &dockercompat.ComponentVersion{
Name: "rootlesskit",
Version: fields[2],
}, nil

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread pkg/infoutil/infoutil.go Outdated
// getMobySysInfo returns the moby system info for the given cgroup manager

func rootlessKitVersion() dockercompat.ComponentVersion {
stdout, err := exec.Command("rootlesskit", "--version").Output()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@AkihiroSuda

Copy link
Copy Markdown
Member

There was already a PR #4937 from @MD-Mushfiqur123 , but it seems accidentally closed.

@amarkdotdev amarkdotdev force-pushed the feat/version-rootlesskit branch from 02bf394 to 16aaa26 Compare June 21, 2026 05:50
@amarkdotdev

Copy link
Copy Markdown
Contributor Author

Thanks @AkihiroSuda for the review. I've reworked the implementation per your feedback:

  • Replaced exec.Command("rootlesskit", "--version") with the RootlessKit API socket: rootlessutil.NewRootlessKitClient()client.Info(ctx)info.Version
  • ctx is propagated from ServerVersion(ctx, ...) into the new rootlessKitVersion(ctx) function
  • Removed the string-parsing code and its unit test (no longer needed with structured API response)

The function is still only called when rootlessutil.IsRootless() is true. If the API socket is unavailable or the Info call fails, it logs a warning and returns the component without a version (same graceful-degradation pattern as runcVersion).

Regarding PR #4937 from @MD-Mushfiqur123 — I saw it was accidentally closed. Happy to step aside if they'd like to re-open theirs, or keep this one going if that's simpler for you.

@amarkdotdev amarkdotdev force-pushed the feat/version-rootlesskit branch from 16aaa26 to dd8e035 Compare June 21, 2026 06:37
Comment thread pkg/infoutil/infoutil.go
}
return dockercompat.ComponentVersion{
Name: "rootlesskit",
Version: info.Version,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As in Docker, it should also expose ApiVersion, NetworkDriver, etc.
#4971 (comment)

Please confirm that the output format corresponds to Docker.

@amarkdotdev amarkdotdev force-pushed the feat/version-rootlesskit branch from dd8e035 to 120deb8 Compare June 21, 2026 08:48
@amarkdotdev

Copy link
Copy Markdown
Contributor Author

Done — added ApiVersion, NetworkDriver, and PortDriver to the component Details map, matching Docker's format. The output now looks like: rootlesskit: Version: 2.3.1 ApiVersion: 1.1.1 NetworkDriver: slirp4netns PortDriver: builtin Fields are omitted when nil (e.g. NetworkDriver/PortDriver won't show if the info response doesn't include them). PTAL.

Comment thread pkg/infoutil/infoutil.go
log.L.WithError(err).Warnf("unable to retrieve RootlessKit version via API")
return dockercompat.ComponentVersion{Name: "rootlesskit"}
}
details := map[string]string{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

StateDir is still missing

When running in rootless mode, nerdctl version now includes the
RootlessKit version as a server component, matching the format used
by docker version. The version is retrieved via the RootlessKit API
socket (rootlessutil.NewRootlessKitClient + Info(ctx)) rather than
shelling out to rootlesskit --version, which is more robust and
avoids PATH issues.

The version is only shown when rootless mode is active (i.e. when
rootlessutil.IsRootless() is true). If the API socket is unavailable
or the Info call fails, a warning is logged and the component is
shown without a version string.

Fixes containerd#4936

Signed-off-by: Aaron Mark <64331623+amarkdotdev@users.noreply.github.com>
@amarkdotdev amarkdotdev force-pushed the feat/version-rootlesskit branch from 120deb8 to 1e8a519 Compare June 22, 2026 05:20
@amarkdotdev

Copy link
Copy Markdown
Contributor Author

Added StateDir to the details. Updated output: rootlesskit: Version: 2.3.1 ApiVersion: 1.1.1 StateDir: /run/user/1000/containerd-rootless NetworkDriver: slirp4netns PortDriver: builtin

@AkihiroSuda AkihiroSuda left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks

@AkihiroSuda AkihiroSuda added this to the v2.3.4 milestone Jun 22, 2026

@ChengyuZhu6 ChengyuZhu6 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@ChengyuZhu6 ChengyuZhu6 merged commit 478c649 into containerd:main Jun 22, 2026
74 of 82 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nerdctl version should print the version of RootlessKit (in the same format as docker version)

3 participants