Skip to content

Commit 57e2f6e

Browse files
authored
Merge pull request containerd#4208 from AkihiroSuda/fix-1536
oci-hook: add /usr/sbin:/sbin to PATH for iptables
2 parents 87fdc02 + 4a39563 commit 57e2f6e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pkg/cmd/container/create.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,8 @@ func withNerdctlOCIHook(cmd string, args []string) (oci.SpecOpts, error) {
568568
}
569569

570570
args = append([]string{cmd}, append(args, "internal", "oci-hook")...)
571+
// sbin is appended for iptables https://github.com/containerd/nerdctl/discussions/1536
572+
env := append(os.Environ(), "PATH="+os.Getenv("PATH")+":/usr/sbin:/sbin")
571573
return func(_ context.Context, _ oci.Client, _ *containers.Container, s *specs.Spec) error {
572574
if s.Hooks == nil {
573575
s.Hooks = &specs.Hooks{}
@@ -576,14 +578,14 @@ func withNerdctlOCIHook(cmd string, args []string) (oci.SpecOpts, error) {
576578
s.Hooks.CreateRuntime = append(s.Hooks.CreateRuntime, specs.Hook{
577579
Path: cmd,
578580
Args: crArgs,
579-
Env: os.Environ(),
581+
Env: env,
580582
})
581583
argsCopy := append([]string(nil), args...)
582584
psArgs := append(argsCopy, "postStop")
583585
s.Hooks.Poststop = append(s.Hooks.Poststop, specs.Hook{
584586
Path: cmd,
585587
Args: psArgs,
586-
Env: os.Environ(),
588+
Env: env,
587589
})
588590
return nil
589591
}, nil

0 commit comments

Comments
 (0)