| 1026 | } |
| 1027 | |
| 1028 | func writeCIDFile(path, id string) error { |
| 1029 | _, err := os.Stat(path) |
| 1030 | if err == nil { |
| 1031 | return fmt.Errorf("container ID file found, make sure the other container isn't running or delete %s", path) |
| 1032 | } else if errors.Is(err, os.ErrNotExist) { |
| 1033 | f, err := os.Create(path) |
| 1034 | if err != nil { |
| 1035 | return fmt.Errorf("failed to create the container ID file: %s for %s, err: %s", path, id, err) |
| 1036 | } |
| 1037 | defer f.Close() |
| 1038 | |
| 1039 | if _, err := f.WriteString(id); err != nil { |
| 1040 | return err |
| 1041 | } |
| 1042 | return nil |
| 1043 | } |
| 1044 | return err |
| 1045 | } |
| 1046 | |
| 1047 | // generateLogConfig creates a LogConfig for the current container store |
| 1048 | func generateLogConfig(dataStore string, id string, logDriver string, logOpt []string, ns, address string) (logConfig logging.LogConfig, err error) { |