summaryrefslogtreecommitdiff
path: root/cmd/podman/create.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-03-22 13:44:32 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-03-23 12:49:39 +0000
commitc55e371365ef219422da6cfe15e30d9a54d6aff3 (patch)
tree0c70de90ba5db775965985537dc260c008f27849 /cmd/podman/create.go
parentd364d41e1b1cf42d11b383fb02fbaa07e8b156f7 (diff)
downloadpodman-c55e371365ef219422da6cfe15e30d9a54d6aff3.tar.gz
podman-c55e371365ef219422da6cfe15e30d9a54d6aff3.tar.bz2
podman-c55e371365ef219422da6cfe15e30d9a54d6aff3.zip
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
Diffstat (limited to 'cmd/podman/create.go')
-rw-r--r--cmd/podman/create.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/cmd/podman/create.go b/cmd/podman/create.go
index af065817f..8f9e82805 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"))
}