GoogleContainerTools/skaffold · error
creating container in local docker
Error message
creating container in local docker
What it means
Task.Exec in Skaffold's docker action runner creates and starts the test container via client.Run (create + start + attach). If that Docker API sequence fails, the error is wrapped as "creating container in local docker". The test never starts, and the container ID is not yet tracked for later cleanup.
Source
Thrown at pkg/skaffold/actions/docker/task.go:99
execEnv: execEnv,
}
}
func (t Task) Name() string {
return t.name
}
func (t Task) Exec(ctx context.Context, out io.Writer) error {
cn := t.containerName(ctx, t.cfg.Name)
opts, err := t.containerCreateOpts(ctx, cn)
if err != nil {
return err
}
statusCh, errCh, id, err := t.client.Run(ctx, out, *opts)
if err != nil {
return errors.Wrap(err, "creating container in local docker")
}
t.execEnv.TrackContainerFromBuild(graph.Artifact{
ImageName: t.cfg.Name,
Tag: t.cfg.Name,
}, id, cn)
var containerErr error
select {
case containerErr = <-errCh:
case status := <-statusCh:
if status.StatusCode != 0 {
containerErr = errors.New(fmt.Sprintf("%q running container image %q errored during run with status code: %d", t.name, opts.ContainerConfig.Image, status.StatusCode))
}
case <-ctx.Done():
containerErr = ctx.Err()
if err := t.client.Stop(context.TODO(), id, util.Ptr(time.Second*0)); err != nil {
containerErr = errView on GitHub (pinned to a1189de023)
Solutions
- Run `docker images` to confirm the artifact image exists locally; build or pull it first if missing.
- Check the Docker daemon is up and the socket is accessible (`docker info`); start it or fix socket permissions.
- Inspect the unwrapped docker error for specifics: name conflict → remove the old container; mount error → fix the host path; port error → free the port.
- If using a remote/alternate docker context, set DOCKER_HOST/context to the one holding the image.
- Retry after fixing; Exec failures here are deterministic, not transient.
Example fix
// before
task, _ := NewTask(cfg, env); err := task.Exec(ctx, out)
// after
if _, _, err := exec.Command("docker", "image", "inspect", cfg.Name).Run(); err != nil {
return fmt.Errorf("image %s not in local docker; build it first", cfg.Name)
}
if err := task.Exec(ctx, out); err != nil { return err } Defensive patterns
Strategy: validation
Validate before calling
// pre-flight before Exec
if err := exec.Command("docker", "image", "inspect", cfg.Name).Run(); err != nil {
return fmt.Errorf("image %s missing from local docker", cfg.Name)
}
if err := exec.Command("docker", "info").Run(); err != nil {
return errors.New("docker daemon not reachable")
} Prevention
- Build images into the same docker daemon/context used by the task.
- Remove leftover containers with colliding names before runs.
- Verify mounts, ports, and env config before invoking Exec.
When it happens
Trigger: Calling Exec (via execAndLog) when docker client.Run fails: referenced image not present locally and pull fails, invalid container config (bad entrypoint/env/mounts), port conflicts, name collision with an existing container, or the Docker daemon is down.
Common situations: The image was built by another engine or on a remote host so it is not in the local daemon; volume mount paths do not exist on the host; docker daemon not running or user lacks permission to /var/run/docker.sock; container name already in use from a previous crashed run.
Related errors
- creating container in local docker
- %q running container image %q errored during run with status
- docker deployment not supported alongside cluster deployment
- INIT_DOCKER_NETWORK_CONTAINER_DOES_NOT_EXIST
- executing build: %w
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/cbcf1082b676841d.
Report an issue: GitHub.