Skip to content

Commit

Permalink
If cidfile exists, do not proceed
Browse files Browse the repository at this point in the history
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 <[email protected]>

Closes: #531
Approved by: rhatdan
  • Loading branch information
baude authored and rh-atomic-bot committed Mar 23, 2018
1 parent d364d41 commit c55e371
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/podman/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
Expand Down
3 changes: 3 additions & 0 deletions cmd/podman/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
Expand Down

0 comments on commit c55e371

Please sign in to comment.