{"record":{"id":"be72102d0ec8701e","repo":"GoogleContainerTools/skaffold","slug":"cleaning-up-skaffold-created-network-be7210","errorCode":null,"errorMessage":"cleaning up skaffold created network","messagePattern":"cleaning up skaffold created network","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/skaffold/deploy/docker/deploy.go","lineNumber":378,"sourceCode":"\t\t}\n\t\treturn nil\n\t}\n\tfor _, container := range d.tracker.DeployedContainers() {\n\t\tif err := d.client.Delete(ctx, out, container.ID); err != nil {\n\t\t\t// TODO(nkubala): replace with actionable error\n\t\t\treturn errors.Wrap(err, \"cleaning up deployed container\")\n\t\t}\n\t\td.portManager.RelinquishPorts(container.ID)\n\t}\n\n\tfor _, m := range d.debugger.SupportMounts() {\n\t\tif err := d.client.VolumeRemove(ctx, m.Source); err != nil {\n\t\t\treturn errors.Wrap(err, \"cleaning up debug support volume\")\n\t\t}\n\t}\n\n\tif err := d.client.NetworkRemove(ctx, d.network); d.networkDeployed && err != nil {\n\t\treturn errors.Wrap(err, \"cleaning up skaffold created network\")\n\t}\n\n\treturn d.cleanPreviousDeployments(ctx)\n}\n\nfunc (d *Deployer) cleanPreviousDeployments(ctx context.Context) error {\n\tctd, err := d.containersToDelete(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tntd, err := d.networksToDelete(ctx, ctd)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvtd := d.volumesToDelete(ctd)\n","sourceCodeStart":360,"sourceCodeEnd":396,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/deploy/docker/deploy.go#L360-L396","documentation":"If the deployer created a dedicated Docker network, Cleanup removes it with d.client.NetworkRemove, but only when d.networkDeployed is true. A failure removing the network (endpoints still attached, already gone, daemon error) is wrapped with this message.","triggerScenarios":"Deployer.Cleanup reaches d.client.NetworkRemove(ctx, d.network) with d.networkDeployed == true and the daemon returns an error — typically because containers are still connected to the network or it was already deleted.","commonSituations":"Containers still attached because earlier cleanup steps (containers) failed; network manually deleted with `docker network rm`; two skaffold instances sharing one network race to delete it; daemon down during cleanup.","solutions":["Disconnect/remove remaining containers first: `docker network inspect <network>` to see attached endpoints","Run `docker network rm <network>` manually, or `docker network prune`","Re-run `skaffold delete` once the container cleanup succeeds","If the network is already gone, the leftover error is harmless — ignore or upgrade skaffold to tolerate 404","Avoid running concurrent skaffold sessions against the same network"],"exampleFix":"// before\nerror: cleaning up skaffold created network: Error response from daemon: network <id> has active endpoints\n// after\n$ docker network inspect <network>   # find endpoints\n$ docker rm -f <endpoint-container>\n$ docker network rm <network>\n$ skaffold delete","handlingStrategy":"try-catch","validationCode":"if out, err := exec.Command(\"docker\", \"network\", \"inspect\", d.network).CombinedOutput(); err != nil {\n  log.Printf(\"network already absent or uninspectable: %s\", out) // nothing to clean\n}","typeGuard":"null","tryCatchPattern":"if err := deployer.Cleanup(ctx, out); err != nil && strings.Contains(err.Error(), \"cleaning up skaffold created network\") {\n  log.Printf(\"network cleanup deferred: %v\", err)\n  exec.Command(\"docker\", \"network\", \"prune\", \"-f\").Run()\n}","preventionTips":["Fix container cleanup first — attached endpoints block network removal","Don't run concurrent skaffold sessions sharing a network","Avoid manual `docker network rm` of the skaffold network","Re-run `skaffold delete` or `docker network prune` afterwards"],"tags":["docker","cleanup","network"],"backgroundTag":"network-remove-failed","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}