GoogleContainerTools/skaffold · warning

cleaning up skaffold created network

Error message

cleaning up skaffold created network

What it means

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.

Source

Thrown at pkg/skaffold/verify/docker/verify.go:354

func (v *Verifier) Cleanup(ctx context.Context, out io.Writer, dryRun bool) error {
	if dryRun {
		for _, container := range v.tracker.DeployedContainers() {
			output.Yellow.Fprintln(out, container.ID)
		}
		return nil
	}
	for _, container := range v.tracker.DeployedContainers() {
		v.client.Stop(ctx, container.ID, nil)
		if err := v.client.Remove(ctx, container.ID); err != nil {
			olog.Entry(ctx).Debugf("cleaning up deployed container: %s", err.Error())
		}
		v.portManager.RelinquishPorts(container.ID)
	}

	if !v.networkFlagPassed {
		err := v.client.NetworkRemove(ctx, v.network)
		return errors.Wrap(err, "cleaning up skaffold created network")
	}
	return nil
}

func (v *Verifier) GetLogger() log.Logger {
	return v.logger
}

func (v *Verifier) GetStatusMonitor() status.Monitor {
	return v.monitor
}

func (v *Verifier) RegisterLocalImages([]graph.Artifact) {
	// all images are local, so this is a noop
}

func (v *Verifier) timeout(duration *time.Duration) <-chan time.Time {
	if duration != nil {

View on GitHub (pinned to a1189de023)

Solutions

  1. Check for containers still attached: `docker network inspect <network>` and remove leftover containers
  2. If the network is already gone, the failure is benign — rerun cleanup or ignore
  3. Manually remove: `docker network rm <network>` after stopping leftover containers
  4. Report a bug if skaffold consistently leaks networks with active containers

Example fix

// before cleanup ordering issue: remove network while container alive
// after: ensure container removal (and port release) happens before NetworkRemove
Defensive patterns

Strategy: try-catch

Validate before calling

// Detect stale network before cleanup
if _, err := exec.Command("docker", "network", "inspect", networkName).Output(); err != nil {
    // network already gone; nothing to clean
    return nil
}

Try / catch

if err := verifier.Cleanup(ctx, out, ga); err != nil {
    if strings.Contains(err.Error(), "cleaning up skaffold created network") {
        log.Printf("network cleanup issue (possibly benign): %v", err)
        exec.Command("docker", "network", "prune", "-f").Run()
        return nil
    }
    return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/ce6aea63622171eb. Report an issue: GitHub.