diff --git a/cmd/podman/create.go b/cmd/podman/create.go index af065817f2..8f9e828058 100644 --- a/cmd/podman/create.go +++ b/cmd/podman/create.go @@ -159,6 +159,9 @@ func createCmd(c *cli.Context) error { } 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 { return errors.Wrapf(err, "unable to write cidfile %s", c.String("cidfile")) } diff --git a/cmd/podman/run.go b/cmd/podman/run.go index 53b7083e35..523b973fb1 100644 --- a/cmd/podman/run.go +++ b/cmd/podman/run.go @@ -37,6 +37,9 @@ func runCmd(c *cli.Context) error { } 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 { return errors.Wrapf(err, "unable to write cidfile %s", c.String("cidfile")) }