mirror of
https://github.com/containers/podman.git
synced 2025-07-24 07:58:04 +08:00
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:
@ -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"))
|
||||
}
|
||||
|
@ -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"))
|
||||
}
|
||||
|
Reference in New Issue
Block a user