{"record":{"id":"e3df009dcf0c108e","repo":"Billionmail/BillionMail","slug":"failed-to-connect-to-docker-api-v-e3df00","errorCode":null,"errorMessage":"failed to connect to Docker API: %v","messagePattern":"failed to connect to Docker API: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/service/domains/domains.go","lineNumber":996,"sourceCode":"\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif info.IsDir() {\n\t\t\treturn os.Chmod(path, 0755)\n\t\t}\n\t\tif strings.HasSuffix(path, \".private\") || strings.HasSuffix(path, \".pub\") {\n\t\t\treturn os.Chmod(path, 0644)\n\t\t}\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to change DKIM file permissions: %v\", err)\n\t}\n\n\t// 6. Restart rspamd service\n\tdk, err := docker.NewDockerAPI()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to connect to Docker API: %v\", err)\n\t}\n\tdefer dk.Close()\n\n\terr = dk.RestartContainerByName(ctx, consts.SERVICES.Rspamd)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to restart rspamd container: %v\", err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":978,"sourceCodeEnd":1007,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/domains/domains.go#L978-L1007","documentation":"After fixing permissions the function must restart the rspamd container, which requires a Docker API client. This error means docker.NewDockerAPI() failed — the app could not establish a connection to the Docker daemon socket.","triggerScenarios":"docker.NewDockerAPI() returns an error: /var/run/docker.sock missing or not mounted, DOCKER_HOST misconfigured, daemon not running, or socket permission denied for the process user.","commonSituations":"App runs in a container without the Docker socket bind-mounted; the user is not in the docker group; Docker daemon stopped on host; rootless Docker socket path differs from the default.","solutions":["Confirm the Docker daemon is running (systemctl status docker)","Bind-mount /var/run/docker.sock into the app container and set the correct DOCKER_HOST","Add the running user to the docker group or grant socket access","Verify the docker client library/SDK version matches the daemon API version"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if _, err := os.Stat(\"/var/run/docker.sock\"); err != nil {\n\treturn fmt.Errorf(\"docker socket not available: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := RepairDKIMSigningConfig(ctx); err != nil && strings.Contains(err.Error(), \"failed to connect to Docker API\") {\n\tlog.Printf(\"ensure docker socket is mounted and daemon is up: %v\", err)\n}","preventionTips":["Mount /var/run/docker.sock into the app container","Add the app user to the docker group","Health-check Docker connectivity at startup","Set DOCKER_HOST explicitly when using a remote/rootless daemon"],"tags":["docker","network","socket","connection"],"backgroundTag":"docker-daemon-unreachable","analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}