summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorPaul Holzinger <paul.holzinger@web.de>2020-08-20 11:07:36 +0200
committerPaul Holzinger <paul.holzinger@web.de>2020-08-20 16:28:45 +0200
commitd10bc9f045ad7bc52d03bbf9462b3f94e693ccd1 (patch)
treef6287c614cbc2c72355cb27d268267ee63c6ce52 /cmd/podman
parent7865db54793fabd5eb17f105292277a3cd74930c (diff)
downloadpodman-d10bc9f045ad7bc52d03bbf9462b3f94e693ccd1.tar.gz
podman-d10bc9f045ad7bc52d03bbf9462b3f94e693ccd1.tar.bz2
podman-d10bc9f045ad7bc52d03bbf9462b3f94e693ccd1.zip
fix pod creation with "new:" syntax followup + allow hostname
Fixes: 4c75fe3f70ed ("fix pod creation with "new:" syntax") Commit 4c75fe3f70ed passes all net options to the pod but forgot to unset the options for the container creation. This leads to erros when using flags like `--ip` since we tried setting the ip on the pod and container which obviously fails. I didn't notice the bug because we don't throw an error when specifing port bindings on a container which joins the pods network namespace. (#7373) Also allow the use of `--hostname` and pass that option to the pod and unset it for the container. The container has to use the pods hostname anyway. This would error otherwise. Added tests to prevent regression. Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/containers/create.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/cmd/podman/containers/create.go b/cmd/podman/containers/create.go
index 6eec93f98..801547033 100644
--- a/cmd/podman/containers/create.go
+++ b/cmd/podman/containers/create.go
@@ -297,7 +297,12 @@ func createPodIfNecessary(s *specgen.SpecGenerator, netOpts *entities.NetOptions
Infra: true,
Net: netOpts,
CreateCommand: os.Args,
+ Hostname: s.ContainerBasicConfig.Hostname,
}
+ // Unset config values we passed to the pod to prevent them being used twice for the container and pod.
+ s.ContainerBasicConfig.Hostname = ""
+ s.ContainerNetworkConfig = specgen.ContainerNetworkConfig{}
+
s.Pod = podName
return registry.ContainerEngine().PodCreate(context.Background(), createOptions)
}