summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2020-09-14 15:18:26 +0200
committerValentin Rothberg <rothberg@redhat.com>2020-09-15 10:18:30 +0200
commit155d43631eb9ddadee6f2f277436e35c6ef58406 (patch)
tree54178eb5a1c406cdeabdef5b35b61de398b51cad /libpod
parent02f8acce2a8484e29469e47dbe2cd1ee88700092 (diff)
downloadpodman-155d43631eb9ddadee6f2f277436e35c6ef58406.tar.gz
podman-155d43631eb9ddadee6f2f277436e35c6ef58406.tar.bz2
podman-155d43631eb9ddadee6f2f277436e35c6ef58406.zip
rootless CNI: extract env and cmd from image
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/rootless_cni_linux.go21
1 files changed, 18 insertions, 3 deletions
diff --git a/libpod/rootless_cni_linux.go b/libpod/rootless_cni_linux.go
index 0f3db1f38..31097dd16 100644
--- a/libpod/rootless_cni_linux.go
+++ b/libpod/rootless_cni_linux.go
@@ -13,6 +13,7 @@ import (
"github.com/containernetworking/plugins/pkg/ns"
"github.com/containers/podman/v2/libpod/define"
"github.com/containers/podman/v2/libpod/image"
+ "github.com/containers/podman/v2/pkg/env"
"github.com/containers/podman/v2/pkg/util"
"github.com/containers/storage/pkg/lockfile"
"github.com/hashicorp/go-multierror"
@@ -257,9 +258,23 @@ func startRootlessCNIInfraContainer(ctx context.Context, r *Runtime) (*Container
Options: []string{"ro"},
}
g.AddMount(etcCNINetD)
- // FIXME: how to propagate ProcessArgs and Envs from Dockerfile?
- g.SetProcessArgs([]string{"sleep", "infinity"})
- g.AddProcessEnv("CNI_PATH", "/opt/cni/bin")
+
+ inspectData, err := newImage.Inspect(ctx)
+ if err != nil {
+ return nil, err
+ }
+ imageEnv, err := env.ParseSlice(inspectData.Config.Env)
+ if err != nil {
+ return nil, err
+ }
+ for k, v := range imageEnv {
+ g.AddProcessEnv(k, v)
+ }
+ if len(inspectData.Config.Cmd) == 0 {
+ return nil, errors.Errorf("rootless CNI infra image %q has no command specified", imageName)
+ }
+ g.SetProcessArgs(inspectData.Config.Cmd)
+
var options []CtrCreateOption
options = append(options, WithRootFSFromImage(newImage.ID(), imageName, imageName))
options = append(options, WithCtrNamespace(rootlessCNIInfraContainerNamespace))