mirror of
https://github.com/containers/podman.git
synced 2025-06-27 13:38:49 +08:00
Merge pull request #7388 from Luap99/new-pod
fix pod creation with "new:" syntax followup + allow hostname
This commit is contained in:
@ -297,7 +297,12 @@ func createPodIfNecessary(s *specgen.SpecGenerator, netOpts *entities.NetOptions
|
|||||||
Infra: true,
|
Infra: true,
|
||||||
Net: netOpts,
|
Net: netOpts,
|
||||||
CreateCommand: os.Args,
|
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
|
s.Pod = podName
|
||||||
return registry.ContainerEngine().PodCreate(context.Background(), createOptions)
|
return registry.ContainerEngine().PodCreate(context.Background(), createOptions)
|
||||||
}
|
}
|
||||||
|
@ -531,8 +531,8 @@ var _ = Describe("Podman run networking", func() {
|
|||||||
SkipIfRemote()
|
SkipIfRemote()
|
||||||
SkipIfRootless()
|
SkipIfRootless()
|
||||||
netName := "podmantestnetwork"
|
netName := "podmantestnetwork"
|
||||||
ipAddr := "10.20.30.128"
|
ipAddr := "10.25.30.128"
|
||||||
create := podmanTest.Podman([]string{"network", "create", "--subnet", "10.20.30.0/24", netName})
|
create := podmanTest.Podman([]string{"network", "create", "--subnet", "10.25.30.0/24", netName})
|
||||||
create.WaitWithDefaultTimeout()
|
create.WaitWithDefaultTimeout()
|
||||||
Expect(create.ExitCode()).To(BeZero())
|
Expect(create.ExitCode()).To(BeZero())
|
||||||
|
|
||||||
@ -540,5 +540,33 @@ var _ = Describe("Podman run networking", func() {
|
|||||||
run.WaitWithDefaultTimeout()
|
run.WaitWithDefaultTimeout()
|
||||||
Expect(run.ExitCode()).To(BeZero())
|
Expect(run.ExitCode()).To(BeZero())
|
||||||
Expect(run.OutputToString()).To(ContainSubstring(ipAddr))
|
Expect(run.OutputToString()).To(ContainSubstring(ipAddr))
|
||||||
|
|
||||||
|
netrm := podmanTest.Podman([]string{"network", "rm", netName})
|
||||||
|
netrm.WaitWithDefaultTimeout()
|
||||||
|
Expect(netrm.ExitCode()).To(BeZero())
|
||||||
|
})
|
||||||
|
|
||||||
|
It("podman run with new:pod and static-ip", func() {
|
||||||
|
SkipIfRemote()
|
||||||
|
SkipIfRootless()
|
||||||
|
netName := "podmantestnetwork2"
|
||||||
|
ipAddr := "10.25.40.128"
|
||||||
|
podname := "testpod"
|
||||||
|
create := podmanTest.Podman([]string{"network", "create", "--subnet", "10.25.40.0/24", netName})
|
||||||
|
create.WaitWithDefaultTimeout()
|
||||||
|
Expect(create.ExitCode()).To(BeZero())
|
||||||
|
|
||||||
|
run := podmanTest.Podman([]string{"run", "-t", "-i", "--rm", "--pod", "new:" + podname, "--net", netName, "--ip", ipAddr, ALPINE, "ip", "addr"})
|
||||||
|
run.WaitWithDefaultTimeout()
|
||||||
|
Expect(run.ExitCode()).To(BeZero())
|
||||||
|
Expect(run.OutputToString()).To(ContainSubstring(ipAddr))
|
||||||
|
|
||||||
|
podrm := podmanTest.Podman([]string{"pod", "rm", "-f", podname})
|
||||||
|
podrm.WaitWithDefaultTimeout()
|
||||||
|
Expect(podrm.ExitCode()).To(BeZero())
|
||||||
|
|
||||||
|
netrm := podmanTest.Podman([]string{"network", "rm", netName})
|
||||||
|
netrm.WaitWithDefaultTimeout()
|
||||||
|
Expect(netrm.ExitCode()).To(BeZero())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -867,6 +867,14 @@ USER mail`
|
|||||||
Expect(match).To(BeTrue())
|
Expect(match).To(BeTrue())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman run --pod new with hostname", func() {
|
||||||
|
hostname := "abc"
|
||||||
|
session := podmanTest.Podman([]string{"run", "--pod", "new:foobar", "--hostname", hostname, ALPINE, "cat", "/etc/hostname"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
Expect(session.OutputToString()).To(ContainSubstring(hostname))
|
||||||
|
})
|
||||||
|
|
||||||
It("podman run --rm should work", func() {
|
It("podman run --rm should work", func() {
|
||||||
session := podmanTest.Podman([]string{"run", "--name", "test", "--rm", ALPINE, "ls"})
|
session := podmanTest.Podman([]string{"run", "--name", "test", "--rm", ALPINE, "ls"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
|
Reference in New Issue
Block a user