From c55e371365ef219422da6cfe15e30d9a54d6aff3 Mon Sep 17 00:00:00 2001 From: baude Date: Thu, 22 Mar 2018 13:44:32 -0500 Subject: 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 Closes: #531 Approved by: rhatdan --- cmd/podman/run.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'cmd/podman/run.go') diff --git a/cmd/podman/run.go b/cmd/podman/run.go index 53b7083e3..523b973fb 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")) } -- cgit v1.2.3-54-g00ecf