mirror of
https://github.com/containers/podman.git
synced 2025-05-28 21:46:51 +08:00
The cidfile should be created when the container is created
Currently if you run an interactive session of podman run and specifiy the --cidfile option, the cidfile will not get created until the container finishes running. If you run a detached container, it will get created right away. This Patch creates the cidfile as soon as the container is created. This could allow other tools to use the cidefile on all running containers. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
@ -638,3 +638,18 @@ func ValidateSysctls(strSlice []string) (map[string]string, error) {
|
||||
func DefaultContainerConfig() *config.Config {
|
||||
return containerConfig
|
||||
}
|
||||
|
||||
func CreateCidFile(cidfile string, id string) error {
|
||||
cidFile, err := OpenExclusiveFile(cidfile)
|
||||
if err != nil {
|
||||
if os.IsExist(err) {
|
||||
return errors.Errorf("container id file exists. Ensure another container is not using it or delete %s", cidfile)
|
||||
}
|
||||
return errors.Errorf("error opening cidfile %s", cidfile)
|
||||
}
|
||||
if _, err = cidFile.WriteString(id); err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
cidFile.Close()
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user