{"record":{"id":"ce6aea63622171eb","repo":"GoogleContainerTools/skaffold","slug":"cleaning-up-skaffold-created-network-ce6aea","errorCode":null,"errorMessage":"cleaning up skaffold created network","messagePattern":"cleaning up skaffold created network","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/skaffold/verify/docker/verify.go","lineNumber":354,"sourceCode":"\nfunc (v *Verifier) Cleanup(ctx context.Context, out io.Writer, dryRun bool) error {\n\tif dryRun {\n\t\tfor _, container := range v.tracker.DeployedContainers() {\n\t\t\toutput.Yellow.Fprintln(out, container.ID)\n\t\t}\n\t\treturn nil\n\t}\n\tfor _, container := range v.tracker.DeployedContainers() {\n\t\tv.client.Stop(ctx, container.ID, nil)\n\t\tif err := v.client.Remove(ctx, container.ID); err != nil {\n\t\t\tolog.Entry(ctx).Debugf(\"cleaning up deployed container: %s\", err.Error())\n\t\t}\n\t\tv.portManager.RelinquishPorts(container.ID)\n\t}\n\n\tif !v.networkFlagPassed {\n\t\terr := v.client.NetworkRemove(ctx, v.network)\n\t\treturn errors.Wrap(err, \"cleaning up skaffold created network\")\n\t}\n\treturn nil\n}\n\nfunc (v *Verifier) GetLogger() log.Logger {\n\treturn v.logger\n}\n\nfunc (v *Verifier) GetStatusMonitor() status.Monitor {\n\treturn v.monitor\n}\n\nfunc (v *Verifier) RegisterLocalImages([]graph.Artifact) {\n\t// all images are local, so this is a noop\n}\n\nfunc (v *Verifier) timeout(duration *time.Duration) <-chan time.Time {\n\tif duration != nil {","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/verify/docker/verify.go#L336-L372","documentation":"During Cleanup, the verifier tries to remove the Docker network it created for verification. If skaffold created the network itself (networkFlagPassed is false) and NetworkRemove fails, this error wraps the docker API failure.","triggerScenarios":"Cleanup is called after verification and v.client.NetworkRemove(ctx, v.network) fails — network already removed, still in use by containers, or docker daemon errors.","commonSituations":"Verify containers not fully stopped/removed before network removal; user manually deleted the network mid-run; docker daemon restart lost network state; leaked containers holding the network.","solutions":["Check for containers still attached: `docker network inspect <network>` and remove leftover containers","If the network is already gone, the failure is benign — rerun cleanup or ignore","Manually remove: `docker network rm <network>` after stopping leftover containers","Report a bug if skaffold consistently leaks networks with active containers"],"exampleFix":"// before cleanup ordering issue: remove network while container alive\n// after: ensure container removal (and port release) happens before NetworkRemove","handlingStrategy":"try-catch","validationCode":"// Detect stale network before cleanup\nif _, err := exec.Command(\"docker\", \"network\", \"inspect\", networkName).Output(); err != nil {\n    // network already gone; nothing to clean\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := verifier.Cleanup(ctx, out, ga); err != nil {\n    if strings.Contains(err.Error(), \"cleaning up skaffold created network\") {\n        log.Printf(\"network cleanup issue (possibly benign): %v\", err)\n        exec.Command(\"docker\", \"network\", \"prune\", \"-f\").Run()\n        return nil\n    }\n    return err\n}","preventionTips":["Don't manually delete docker networks while a verify run is active","Ensure all verify containers are stopped before network removal","Periodically run `docker network prune` to clear leaked networks"],"tags":["docker","cleanup","network"],"backgroundTag":"docker-network-cleanup-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"}