nektos/act · warning

failed to remove container: %w

Error message

failed to remove container: %w

What it means

containerReference.remove force-removes the job container with RemoveVolumes+Force at cleanup time. The error is deliberately only logged (logger.Error), not returned — cleanup continues and remove returns nil — so this message appears in logs but does not fail the run.

Source

Thrown at pkg/container/docker_run.go:345

		cr.id = ""
		return nil
	}
}

func (cr *containerReference) remove() common.Executor {
	return func(ctx context.Context) error {
		if cr.id == "" {
			return nil
		}

		logger := common.Logger(ctx)
		_, err := cr.cli.ContainerRemove(ctx, cr.id, client.ContainerRemoveOptions{
			RemoveVolumes: true,
			Force:         true,
		})
		if err != nil {
			logger.Error(fmt.Errorf("failed to remove container: %w", err))
		}

		logger.Debugf("Removed container: %v", cr.id)
		cr.id = ""
		return nil
	}
}

func (cr *containerReference) mergeContainerConfigs(ctx context.Context, config *container.Config, hostConfig *container.HostConfig) (*container.Config, *container.HostConfig, error) {
	logger := common.Logger(ctx)
	input := cr.input

	if input.Options == "" {
		return config, hostConfig, nil
	}

	// parse configuration from CLI container.options
	flags := pflag.NewFlagSet("container_flags", pflag.ContinueOnError)

View on GitHub (pinned to 4f41128141)

Solutions

  1. Treat it as a warning: it does not fail the job — check whether the run result matters
  2. docker ps -a | grep act- to find leftovers, then docker rm -f them or docker container prune
  3. If it recurs, investigate daemon health/storage (docker system df, dmesg for overlay errors)
  4. Avoid running multiple act instances that reuse identical container names
Defensive patterns

Strategy: try-catch

Validate before calling

# shell: clean leftovers before a run
docker ps -a --format '{{.Names}}' | grep '^act-' | xargs -r docker rm -f

Try / catch

// Note: remove() already swallows the error internally (logs only, returns nil).
// If calling the API directly, mirror that:
if _, err := cli.ContainerRemove(ctx, id, client.ContainerRemoveOptions{RemoveVolumes: true, Force: true}); err != nil {
    log.Warnf("container remove failed (continuing): %w", err)
}

Prevention

When it happens

Trigger: ContainerRemove failing during cleanup: container already gone (race with a previous cleanup), daemon unreachable at teardown, or a container stuck in a state that even Force cannot remove.

Common situations: Concurrent act runs or interrupted runs where the container vanished; Docker daemon shut down before the job's finally block ran; overlayfs/network in a bad state on the host.

Related errors


AI-assisted analysis of nektos/act@4f41128141 (2026-08-15). Data as JSON: /api/errors/e3d888db685d2393. Report an issue: GitHub.