Billionmail/BillionMail · error
failed to write temporary output file: %v
Error message
failed to write temporary output file: %v
What it means
After modification, the new compose content is written to the container-side temp file (temp_docker-compose_addnetwork.yml) so it can be chroot-copied to the final docker-compose_addnetwork.yml on the host. If gfile.PutContents fails, the update aborts and rollback runs. This is a local filesystem write failure inside the container.
Source
Thrown at core/internal/service/multi_ip_domain/config_manager.go:219
if gfile.Exists(tempDockerComposePath) {
os.Remove(tempDockerComposePath)
g.Log().Debugf(ctx, "Cleaned up temporary file: %s", tempDockerComposePath)
}
}()
g.Log().Debugf(ctx, "Successfully read docker-compose.yml file, size: %d bytes", len(content))
newContent, err := m.modifyDockerComposeText(ctx, content, configs)
if err != nil {
return fmt.Errorf("failed to modify docker-compose content: %v", err)
}
// Step 7: Write new file docker-compose_addnetwork.yml
tempOutputPath := filepath.Join(containerDataPath, "temp_docker-compose_addnetwork.yml")
hostTempOutputPath := filepath.Join(hostDataPath, "temp_docker-compose_addnetwork.yml")
// First write to temporary container file
if err := gfile.PutContents(tempOutputPath, newContent); err != nil {
return fmt.Errorf("failed to write temporary output file: %v", err)
}
// 然后从宿主机临时位置复制到最终目标位置
copyOutputCmd := []string{
"/bin/sh", "-c",
fmt.Sprintf(`chroot /host_root cp "%s" "%s"`, hostTempOutputPath, outputPath),
}
result, err = dk.ExecHostCommand(ctx, copyOutputCmd)
if err != nil || result.ExitCode != 0 {
if gfile.Exists(tempOutputPath) {
os.Remove(tempOutputPath)
}
return gerror.New("failed to copy output file to destination")
}
// Cleanup temporary output file
if gfile.Exists(tempOutputPath) {View on GitHub (pinned to fc36c76c05)
Solutions
- Check the wrapped %v OS error; free disk space on the core/data volume (df -h) and delete stale temp_* files.
- Fix ownership/permissions of the container data directory for the running process user.
- Verify the volume is mounted writable (docker inspect) and remount if read-only.
- Retry ApplyConfigsWithRollback once the filesystem condition is resolved.
Defensive patterns
Strategy: validation
Validate before calling
dir := public.AbsPath("../core/data")
if err := syscall.Access(dir, os.O_WRONLY); err != nil {
return fmt.Errorf("temp dir %s not writable: %v", dir, err)
}
out, _ := exec.Command("df", "-h", dir).Output()
_ = out // ensure adequate free space Try / catch
if err := mgr.ApplyConfigsWithRollback(ctx, configs); err != nil {
if strings.Contains(err.Error(), "failed to write temporary output file") {
// clean stale temp_* files, free space, fix permissions, retry
}
} Prevention
- Schedule cleanup of stale temp_* files in core/data.
- Monitor disk usage on the core-data volume.
- Keep the data directory writable by the service account.
- Unmount/remount volumes only outside apply windows.
When it happens
Trigger: gfile.PutContents(tempOutputPath, newContent) fails: disk full, directory permissions, read-only filesystem, or the directory was removed between creation and write.
Common situations: core/data volume filled up (temp copies accumulate on errors); non-root process lacking write permission; volume unmounted mid-operation.
Related errors
- failed to read temporary docker-compose.yml file: file is em
- project configuration file does not exist: %s
- error reading project configuration file: %v
- error writing project configuration file: %v
- error creating project configuration: %v
AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05).
Data as JSON: /api/errors/56438a0d299e0a2a.
Report an issue: GitHub.