GoogleContainerTools/skaffold · error

creating container in local docker

Error message

creating container in local docker

What it means

In the same docker deployer deploy step, after config/bindings are prepared the deployer runs the artifact container via d.client.Run. Failure of create/start/attach is wrapped as "creating container in local docker". The deployment does not proceed and nothing is tracked in the container tracker.

Source

Thrown at pkg/skaffold/deploy/docker/deploy.go:215

		var mounts []mount.Mount
		for _, m := range d.debugger.SupportMounts() {
			mounts = append(mounts, m)
		}
		opts.Mounts = mounts
	}

	// Filter for the port resource for the given artifact.ImageName
	filteredPFResources := d.filterPortForwardingResources(artifact.ImageName)

	bindings, err := d.portManager.AllocatePorts(artifact.ImageName, filteredPFResources, containerCfg, debugBindings)
	if err != nil {
		return err
	}
	opts.Bindings = bindings

	_, _, id, err := d.client.Run(ctx, out, opts)
	if err != nil {
		return errors.Wrap(err, "creating container in local docker")
	}
	d.TrackContainerFromBuild(artifact, tracker.Container{Name: containerName, ID: id})
	return nil
}

func (d *Deployer) filterPortForwardingResources(imageName string) []*latest.PortForwardResource {
	filteredPFResources := []*latest.PortForwardResource{}
	for _, p := range d.resources {
		if strings.EqualFold(imageName, p.Name) {
			filteredPFResources = append(filteredPFResources, p)
		}
	}
	return filteredPFResources
}

// setupDebugging configures the provided artifact's image for debugging (if applicable).
// The provided container configuration receives any relevant modifications (e.g. ENTRYPOINT, CMD),
// and any init containers for populating the shared debug volume will be created.

View on GitHub (pinned to a1189de023)

Solutions

  1. Verify the image exists locally (`docker image inspect <artifact>`) or load/pull it before deploy.
  2. Confirm docker daemon is reachable (`docker info`) and socket permissions are correct.
  3. Read the wrapped docker error: name conflict → `docker rm -f <container>`; port conflict → free the port or change port mappings; mount error → fix host path.
  4. If the deployment may have left state, clean up leftovers (`docker ps -a --filter name=<name>`) before retrying.
  5. Ensure the docker context matches the environment where images were built.

Example fix

// before
skaffold deploy -d images && ...
// after
docker image inspect my-image || skaffold build
skaffold deploy
Defensive patterns

Strategy: validation

Validate before calling

// pre-flight: image exists and daemon is healthy
if err := exec.Command("docker", "image", "inspect", artifact).Run(); err != nil {
    return fmt.Errorf("image %s not in local docker; run skaffold build first", artifact)
}
if err := exec.Command("docker", "info").Run(); err != nil {
    return errors.New("docker daemon not reachable")
}

Try / catch

// Go
if _, _, _, err := d.client.Run(ctx, out, opts); err != nil {
    werr := errors.Wrap(err, "creating container in local docker")
    // check root cause
    if strings.Contains(err.Error(), "port is already allocated") { /* remap ports */ }
    if strings.Contains(err.Error(), "name already in use") { /* rm leftover */ }
    return werr
}

Prevention

When it happens

Trigger: Calling Deploy (docker deployer) when docker client.Run fails: image not in local daemon, invalid container options, name collision with a leftover container, port binding conflicts from the port-map, or Docker daemon unreachable.

Common situations: Local `skaffold deploy` with docker target after images were pushed/renamed; previous run left a container with the same name; host port already bound; docker daemon down; mounts referencing non-existent host directories.

Related errors


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