@@ -35,6 +35,7 @@ import (
3535 "github.com/containerd/nerdctl/v2/pkg/buildkitutil"
3636 "github.com/containerd/nerdctl/v2/pkg/inspecttypes/dockercompat"
3737 "github.com/containerd/nerdctl/v2/pkg/inspecttypes/native"
38+ "github.com/containerd/nerdctl/v2/pkg/rootlessutil"
3839 "github.com/containerd/nerdctl/v2/pkg/version"
3940)
4041
@@ -142,6 +143,9 @@ func ServerVersion(ctx context.Context, client *containerd.Client) (*dockercompa
142143 runcVersion (),
143144 },
144145 }
146+ if rootlessutil .IsRootless () {
147+ v .Components = append (v .Components , rootlessKitVersion (ctx ))
148+ }
145149 return v , nil
146150}
147151
@@ -233,6 +237,35 @@ func parseRuncVersion(runcVersionStdout []byte) (*dockercompat.ComponentVersion,
233237}
234238
235239// getMobySysInfo returns the moby system info for the given cgroup manager
240+
241+ func rootlessKitVersion (ctx context.Context ) dockercompat.ComponentVersion {
242+ rc , err := rootlessutil .NewRootlessKitClient ()
243+ if err != nil {
244+ log .L .WithError (err ).Warnf ("unable to connect to RootlessKit API socket" )
245+ return dockercompat.ComponentVersion {Name : "rootlesskit" }
246+ }
247+ info , err := rc .Info (ctx )
248+ if err != nil {
249+ log .L .WithError (err ).Warnf ("unable to retrieve RootlessKit version via API" )
250+ return dockercompat.ComponentVersion {Name : "rootlesskit" }
251+ }
252+ details := map [string ]string {
253+ "ApiVersion" : info .APIVersion ,
254+ "StateDir" : info .StateDir ,
255+ }
256+ if info .NetworkDriver != nil {
257+ details ["NetworkDriver" ] = info .NetworkDriver .Driver
258+ }
259+ if info .PortDriver != nil {
260+ details ["PortDriver" ] = info .PortDriver .Driver
261+ }
262+ return dockercompat.ComponentVersion {
263+ Name : "rootlesskit" ,
264+ Version : info .Version ,
265+ Details : details ,
266+ }
267+ }
268+
236269func getMobySysInfo (cgroupManager string ) * sysinfo.SysInfo {
237270 var info dockercompat.Info
238271 info .CgroupVersion = CgroupsVersion ()
0 commit comments