mirror of
https://github.com/containers/podman
synced 2024-10-21 17:53:44 +00:00
create: fix segfault if container name already exists
do not try to use ctr if there was an error. It fixes a segfault when
there is already a container with the same name.
regression introduced by: ba65301c95
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
387d6012ba
commit
0a7b5b4e08
|
@ -257,7 +257,10 @@ func (r *LocalRuntime) Log(c *cliconfig.LogsValues, options *libpod.LogOptions)
|
|||
func (r *LocalRuntime) CreateContainer(ctx context.Context, c *cliconfig.CreateValues) (string, error) {
|
||||
results := shared.NewIntermediateLayer(&c.PodmanCommand, false)
|
||||
ctr, _, err := shared.CreateContainer(ctx, &results, r.Runtime)
|
||||
return ctr.ID(), err
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return ctr.ID(), nil
|
||||
}
|
||||
|
||||
// Run a libpod container
|
||||
|
|
|
@ -70,6 +70,17 @@ var _ = Describe("Podman create", func() {
|
|||
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
|
||||
})
|
||||
|
||||
It("podman create using existing name", func() {
|
||||
session := podmanTest.Podman([]string{"create", "--name=foo", ALPINE, "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
|
||||
|
||||
session = podmanTest.Podman([]string{"create", "--name=foo", ALPINE, "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(125))
|
||||
})
|
||||
|
||||
It("podman create adds annotation", func() {
|
||||
session := podmanTest.Podman([]string{"create", "--annotation", "HELLO=WORLD", ALPINE, "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
|
|
Loading…
Reference in a new issue