nektos/act · critical

Failed to create job container

Error message

Failed to create job container

What it means

After calling container.NewContainer with the assembled job container configuration (network, aliases, binds, privileged/userns flags, platform, options), run_context.go checks whether the returned ExecutionsEnvironment is nil. With the real Docker implementation NewContainer practically never returns nil, but in Docker-less stub builds NewContainer is compiled to 'return nil', so any job that needs a job container immediately fails with 'Failed to create job container'.

Source

Thrown at pkg/runner/run_context.go:414

			WorkingDir:     ext.ToContainerPath(rc.Config.Workdir),
			Image:          image,
			Username:       username,
			Password:       password,
			Name:           name,
			Env:            envList,
			Mounts:         mounts,
			NetworkMode:    jobContainerNetwork,
			NetworkAliases: []string{rc.Name},
			Binds:          binds,
			Stdout:         logWriter,
			Stderr:         logWriter,
			Privileged:     rc.Config.Privileged,
			UsernsMode:     rc.Config.UsernsMode,
			Platform:       rc.Config.ContainerArchitecture,
			Options:        rc.options(ctx),
		})
		if rc.JobContainer == nil {
			return errors.New("Failed to create job container")
		}

		return common.NewPipelineExecutor(
			rc.pullServicesImages(rc.Config.ForcePull),
			rc.JobContainer.Pull(rc.Config.ForcePull),
			rc.stopJobContainer(),
			container.NewDockerNetworkCreateExecutor(networkName).IfBool(createAndDeleteNetwork),
			rc.startServiceContainers(networkName),
			rc.JobContainer.Create(rc.Config.ContainerCapAdd, rc.Config.ContainerCapDrop),
			rc.JobContainer.Start(false),
			rc.JobContainer.Copy(rc.JobContainer.GetActPath()+"/", &container.FileEntry{
				Name: "workflow/event.json",
				Mode: 0o644,
				Body: rc.EventJSON,
			}, &container.FileEntry{
				Name: "workflow/envs.txt",
				Mode: 0o666,
				Body: "",

View on GitHub (pinned to 4f41128141)

Solutions

  1. Use an official act build that includes Docker support (linux/darwin/windows/netbsd, no WITHOUT_DOCKER tag).
  2. Run the job on the host instead: act -P ubuntu-latest=-self-hosted, which skips job container creation.
  3. Verify the binary: an act built Docker-less fails here for every containerized job — switch binaries rather than tweaking workflow options.
  4. For library consumers, guard on build capabilities before invoking containerized runners.

Example fix

# before
act -j build   # job uses container: node:20, act built -tags WITHOUT_DOCKER
# -> Failed to create job container

# after
act -P ubuntu-latest=-self-hosted -j build
Defensive patterns

Strategy: validation

Validate before calling

// When embedding act: verify container support before containerized runs
package main

import (
	"fmt"
	"os/exec"
)

func canCreateJobContainers() error {
	if err := exec.Command("docker", "info").Run(); err != nil {
		return fmt.Errorf("docker unavailable; run jobs with -self-hosted instead of containers: %w", err)
	}
	return nil
}

Type guard

func isNilJobContainer(rc *runner.RunContext) bool {
    return rc.JobContainer == nil
}

Try / catch

err := rc.JobExecutor()(ctx)
if err != nil && strings.Contains(err.Error(), "Failed to create job container") {
    return fmt.Errorf("act binary lacks docker support (stub NewContainer returned nil); use a docker-enabled build or -self-hosted platform mapping")
}

Prevention

When it happens

Trigger: Running a workflow whose job uses a container or a non-self-hosted platform mapping under an act binary built with -tags WITHOUT_DOCKER or for an unsupported GOOS — NewContainer in docker_stub.go returns nil and this check fires during job startup.

Common situations: Distro or downstream act packages compiled without Docker; library users embedding act with the same build tags; expecting act --list to imply act can run containers (list works, execution does not); restricted sandboxes where Docker support was compiled out.

Related errors


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