Skip to content

Commit dc79e90

Browse files
add env to inspect
Signed-off-by: Shubharanshu Mahapatra <[email protected]>
1 parent 39058fb commit dc79e90

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

pkg/inspecttypes/dockercompat/dockercompat.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,11 @@ func ContainerFromNative(n *native.Container) (*Container, error) {
561561
return nil, fmt.Errorf("failed to get blkio settings: %w", err)
562562
}
563563

564+
if n.Spec != nil {
565+
if spec, ok := n.Spec.(*specs.Spec); ok && spec.Process != nil {
566+
c.Config.Env = spec.Process.Env
567+
}
568+
}
564569
return c, nil
565570
}
566571

pkg/inspecttypes/dockercompat/dockercompat_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ func TestContainerFromNative(t *testing.T) {
5757
"nerdctl/hostname": "host1",
5858
},
5959
},
60-
Spec: &specs.Spec{},
60+
Spec: &specs.Spec{
61+
Process: &specs.Process{
62+
Env: []string{"/some/path"},
63+
},
64+
},
6165
Process: &native.Process{
6266
Pid: 10000,
6367
Status: containerd.Status{
@@ -103,6 +107,7 @@ func TestContainerFromNative(t *testing.T) {
103107
"nerdctl/hostname": "host1",
104108
},
105109
Hostname: "host1",
110+
Env: []string{"/some/path"},
106111
},
107112
NetworkSettings: &NetworkSettings{
108113
Ports: &nat.PortMap{},

0 commit comments

Comments
 (0)