Skip to content

Commit b0448ee

Browse files
add env to inspect
Signed-off-by: Shubharanshu Mahapatra <[email protected]>
1 parent 0d7f52c commit b0448ee

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pkg/inspecttypes/dockercompat/dockercompat.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,12 @@ func ContainerFromNative(n *native.Container) (*Container, error) {
540540
pidMode = n.Labels[labels.PIDContainer]
541541
}
542542
c.HostConfig.PidMode = pidMode
543+
544+
if n.Spec != nil {
545+
if spec, ok := n.Spec.(*specs.Spec); ok && spec.Process != nil {
546+
c.Config.Env = spec.Process.Env
547+
}
548+
}
543549
return c, nil
544550
}
545551

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{
@@ -102,6 +106,7 @@ func TestContainerFromNative(t *testing.T) {
102106
"nerdctl/hostname": "host1",
103107
},
104108
Hostname: "host1",
109+
Env: []string{"/some/path"},
105110
},
106111
NetworkSettings: &NetworkSettings{
107112
Ports: &nat.PortMap{},

0 commit comments

Comments
 (0)