mirror of https://github.com/containers/podman.git
If cidfile exists, do not proceed
Both podman run and create have an option to write the container ID to a file. The option is called cidfile. If the cidfile exists, we should not create or run a container but rather output a sensical error message. Resolves: #530 Signed-off-by: baude <bbaude@redhat.com> Closes: #531 Approved by: rhatdan
This commit is contained in:
parent
d364d41e1b
commit
c55e371365
|
@ -159,6 +159,9 @@ func createCmd(c *cli.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.String("cidfile") != "" {
|
if c.String("cidfile") != "" {
|
||||||
|
if _, err := os.Stat(c.String("cidfile")); err == nil {
|
||||||
|
return errors.Errorf("container id file exists. ensure another container is not using it or delete %s", c.String("cidfile"))
|
||||||
|
}
|
||||||
if err := libpod.WriteFile("", c.String("cidfile")); err != nil {
|
if err := libpod.WriteFile("", c.String("cidfile")); err != nil {
|
||||||
return errors.Wrapf(err, "unable to write cidfile %s", c.String("cidfile"))
|
return errors.Wrapf(err, "unable to write cidfile %s", c.String("cidfile"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,9 @@ func runCmd(c *cli.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.String("cidfile") != "" {
|
if c.String("cidfile") != "" {
|
||||||
|
if _, err := os.Stat(c.String("cidfile")); err == nil {
|
||||||
|
return errors.Errorf("container id file exists. ensure another container is not using it or delete %s", c.String("cidfile"))
|
||||||
|
}
|
||||||
if err := libpod.WriteFile("", c.String("cidfile")); err != nil {
|
if err := libpod.WriteFile("", c.String("cidfile")); err != nil {
|
||||||
return errors.Wrapf(err, "unable to write cidfile %s", c.String("cidfile"))
|
return errors.Wrapf(err, "unable to write cidfile %s", c.String("cidfile"))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue