From fbbad04398703359a0d29d8e03bc4fed6e2d95f4 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Fri, 8 Sep 2023 16:02:49 +0200 Subject: [PATCH] pod: fix duplicate volumes from containers.conf If some volumes are specified in containers.conf, they are currently added twice to the containers spec causing the container to fail: $ head -n2 ~/.config/containers/containers.conf [containers] volumes = ["/tmp:/tmp"] $ podman pod create --name foo 7ac7f97f9b74a596332483e4a13e58cb9c8d997e9c5baae46804ae0acc26cbc6 $ podman run --pod=foo alpine true Error: "/tmp": duplicate mount destination The fix is to ignore the setting from containers.conf when setting the pod default configuration. Signed-off-by: Giuseppe Scrivano --- cmd/podman/pods/create.go | 4 ++++ test/system/200-pod.bats | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/cmd/podman/pods/create.go b/cmd/podman/pods/create.go index 5cc4505ff24c..41ead6014a4e 100644 --- a/cmd/podman/pods/create.go +++ b/cmd/podman/pods/create.go @@ -62,6 +62,10 @@ func init() { flags := createCommand.Flags() flags.SetInterspersed(false) common.DefineCreateDefaults(&infraOptions) + // these settings are not applicable to pod create since they are per-container + // and they will end up being duplicated for each container in the pod. + infraOptions.Volume = nil + infraOptions.Mount = nil common.DefineCreateFlags(createCommand, &infraOptions, entities.InfraMode) common.DefineNetFlags(createCommand) diff --git a/test/system/200-pod.bats b/test/system/200-pod.bats index c8ef3a80c488..12e41efecf0d 100644 --- a/test/system/200-pod.bats +++ b/test/system/200-pod.bats @@ -71,6 +71,24 @@ function teardown() { } +@test "podman pod create - custom volumes" { + skip_if_remote "CONTAINERS_CONF_OVERRIDE only affects server side" + image="i.do/not/exist:image" + tmpdir=$PODMAN_TMPDIR/pod-test + mkdir -p $tmpdir + containersconf=$tmpdir/containers.conf + cat >$containersconf <