aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
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
}