Billionmail/BillionMail · error
failed to modify docker-compose content: %v
Error message
failed to modify docker-compose content: %v
What it means
modifyDockerComposeText rewrites the networks section of docker-compose.yml and the postfix service networks as text. If adding custom networks or rewriting the postfix service networks fails (unexpected compose structure), this wrapper aborts the update and triggers Postfix config rollback. The root cause is the inner addCustomNetworksText/modifyPostfixNetworksText error.
Source
Thrown at core/internal/service/multi_ip_domain/config_manager.go:210
// Step 2: 从容器内路径读取复制的文件
// 由于文件映射,容器内可以通过映射路径读到刚才复制的文件
content := gfile.GetContents(tempDockerComposePath)
if content == "" {
return fmt.Errorf("failed to read temporary docker-compose.yml file: file is empty or does not exist")
}
// Cleanup temporary file
defer func() {
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)View on GitHub (pinned to fc36c76c05)
Solutions
- Read the inner error to see which rewrite step failed (addCustomNetworksText vs modifyPostfixNetworksText).
- Restore a stock docker-compose.yml with standard services/networks sections and default formatting, then retry.
- Validate network names/IPs in the configs payload (lowercase alphanumerics/dashes, valid IPs).
- Keep the compose file close to the generated template; avoid restructuring sections this rewriter depends on.
Defensive patterns
Strategy: validation
Validate before calling
content, _ := os.ReadFile(filepath.Join(public.HostWorkDir, "docker-compose.yml"))
if !strings.Contains(string(content), "services:") || !strings.Contains(string(content), "networks:") {
return fmt.Errorf("docker-compose.yml missing services/networks sections; restore stock layout")
}
if !strings.Contains(string(content), "postfix-billionmail") {
return fmt.Errorf("postfix-billionmail service not found in compose file")
} Try / catch
if err := mgr.ApplyConfigsWithRollback(ctx, configs); err != nil {
if strings.Contains(err.Error(), "failed to modify docker-compose content") {
// restore a standard compose file and validate network names before retry
}
} Prevention
- Keep docker-compose.yml structure close to the stock template.
- Validate network names (lowercase, [a-z0-9-]) in configs.
- Diff compose changes through the tool rather than manual restructuring.
- Keep the compose file valid YAML-parseable at all times.
When it happens
Trigger: modifyDockerComposeText returns error: services/networks section missing from the compose text, indentation/structure not matching the parser's expectations, or invalid config entries (bad network name/IP).
Common situations: Users customized docker-compose.yml (comments removed sections, changed formatting) so the text rewriter can't locate the postfix-billionmail service or networks key; config payload has malformed network names.
Related errors
- Not suppliers found
- Model not found
- failed to query group: %w
- failed to check unsubscribe: %w
- the recipient has unsubscribed from the current group and ca
AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05).
Data as JSON: /api/errors/80cf73b1e7d3d8fa.
Report an issue: GitHub.