summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-12-09 09:52:03 -0500
committerDaniel J Walsh <dwalsh@redhat.com>2021-12-09 13:09:02 -0500
commit593d0907c5c11e933be7dbdce98022f76183ea3c (patch)
treebe7e40888a198e58bd9ac64ffe6c4189eb119309 /cmd/podman
parentc7ed2be8d2745eca7a9bcabf7f40e869baa8c5ec (diff)
downloadpodman-593d0907c5c11e933be7dbdce98022f76183ea3c.tar.gz
podman-593d0907c5c11e933be7dbdce98022f76183ea3c.tar.bz2
podman-593d0907c5c11e933be7dbdce98022f76183ea3c.zip
--hostname should be set when using --pod new:foobar
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2030599 When you create pod, it shares the UTS namespace with Containers. Currently the --hostname is not passed to the pod created when you create a container and pod in the same command. Also fix error message on supported --share flags Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/containers/create.go8
-rw-r--r--cmd/podman/containers/run.go2
2 files changed, 7 insertions, 3 deletions
diff --git a/cmd/podman/containers/create.go b/cmd/podman/containers/create.go
index 9b53a730f..a17fcaa1c 100644
--- a/cmd/podman/containers/create.go
+++ b/cmd/podman/containers/create.go
@@ -141,7 +141,7 @@ func create(cmd *cobra.Command, args []string) error {
}
s.RawImageName = rawImageName
- if _, err := createPodIfNecessary(s, cliVals.Net); err != nil {
+ if _, err := createPodIfNecessary(cmd, s, cliVals.Net); err != nil {
return err
}
@@ -335,7 +335,7 @@ func PullImage(imageName string, cliVals entities.ContainerCreateOptions) (strin
// createPodIfNecessary automatically creates a pod when requested. if the pod name
// has the form new:ID, the pod ID is created and the name in the spec generator is replaced
// with ID.
-func createPodIfNecessary(s *specgen.SpecGenerator, netOpts *entities.NetOptions) (*entities.PodCreateReport, error) {
+func createPodIfNecessary(cmd *cobra.Command, s *specgen.SpecGenerator, netOpts *entities.NetOptions) (*entities.PodCreateReport, error) {
if !strings.HasPrefix(s.Pod, "new:") {
return nil, nil
}
@@ -379,6 +379,10 @@ func createPodIfNecessary(s *specgen.SpecGenerator, netOpts *entities.NetOptions
infraOpts := entities.NewInfraContainerCreateOptions()
infraOpts.Net = netOpts
infraOpts.Quiet = true
+ infraOpts.Hostname, err = cmd.Flags().GetString("hostname")
+ if err != nil {
+ return nil, err
+ }
imageName := config.DefaultInfraImage
podGen.InfraImage = imageName
podGen.InfraContainerSpec = specgen.NewSpecGenerator(imageName, false)
diff --git a/cmd/podman/containers/run.go b/cmd/podman/containers/run.go
index 071708b76..9d1b040cc 100644
--- a/cmd/podman/containers/run.go
+++ b/cmd/podman/containers/run.go
@@ -193,7 +193,7 @@ func run(cmd *cobra.Command, args []string) error {
s.RawImageName = rawImageName
runOpts.Spec = s
- if _, err := createPodIfNecessary(s, cliVals.Net); err != nil {
+ if _, err := createPodIfNecessary(cmd, s, cliVals.Net); err != nil {
return err
}