GoogleContainerTools/skaffold · warning
cleaning up skaffold created network
Error message
cleaning up skaffold created network
What it means
ExecEnv.Cleanup in Skaffold's docker action executor removes the Docker network that was created for the test/action run. If client.NetworkRemove fails, the error is wrapped as "cleaning up skaffold created network". This is a teardown-stage failure: the run itself already happened, but resources were not reclaimed.
Source
Thrown at pkg/skaffold/actions/docker/exec_env.go:127
func (e ExecEnv) PrepareActions(ctx context.Context, out io.Writer, allbuilds, _ []graph.Artifact, acsNames []string) ([]actions.Action, error) {
if e.shouldCreateNetwork {
if err := e.client.NetworkCreate(ctx, e.network, nil); err != nil {
return nil, fmt.Errorf("creating skaffold network %s: %w", e.network, err)
}
}
e.logger.Start(ctx, out)
return e.createActions(ctx, out, allbuilds, acsNames)
}
func (e ExecEnv) Cleanup(ctx context.Context, out io.Writer) error {
if !e.shouldCreateNetwork {
return nil
}
if err := e.client.NetworkRemove(ctx, e.network); err != nil {
return errors.Wrap(err, "cleaning up skaffold created network")
}
return nil
}
func (e ExecEnv) Stop() {
e.logger.Stop() // Print the logs of the containers that were not able to print during execution.
}
func (e ExecEnv) createActions(ctx context.Context, out io.Writer, bs []graph.Artifact, acsNames []string) ([]actions.Action, error) {
var trackedBuilds []graph.Artifact
var acs []actions.Action
builtArtifacts := map[string]graph.Artifact{}
for _, b := range bs {
builtArtifacts[b.ImageName] = b
}
View on GitHub (pinned to a1189de023)
Solutions
- Ensure all containers attached to the network are stopped before Cleanup (Stop tasks first, then Cleanup).
- Manually remove the leftover network: `docker network rm <network>` after checking `docker network ls`.
- Check the unwrapped docker error; if 'network has active endpoints', list endpoints with `docker network inspect <network>` and stop them.
- If the daemon restarted, the network may be gone already — treat a not-found error as success in the caller.
- Avoid concurrent runs sharing the same network name; use unique per-run network names.
Example fix
// before
if err := env.Cleanup(ctx, out); err != nil { return err }
// after
if err := env.Cleanup(ctx, out); err != nil {
log.Printf("warning: network cleanup failed (run may still succeed): %v", err)
} Defensive patterns
Strategy: try-catch
Try / catch
// Go
if err := env.Cleanup(ctx, out); err != nil {
// non-fatal teardown failure: log and continue
log.Printf("warning: %v", err)
}
// manual fallback: docker network rm <network> Prevention
- Stop all run containers before Cleanup so the network has no active endpoints.
- Use unique network names per run to avoid cross-run deletion.
- Treat not-found network errors as successful cleanup.
When it happens
Trigger: Calling Cleanup when shouldCreateNetwork is true and NetworkRemove errors: network already removed by another process or concurrent cleanup, network still in use by attached containers, or the Docker daemon is unreachable/restarted.
Common situations: Containers from the run are still running and attached, so Docker refuses to remove the network ("network has active endpoints"); parallel skaffold runs deleting each other's networks; docker daemon restart mid-run; hitting a context cancellation/timeout during teardown.
Related errors
- creating skaffold network %s: %w
- pruning removed container: %w
- pruning images: %w
- unable to remove container: %w
- cleaning up deployed container
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/e04c097a4583e799.
Report an issue: GitHub.