{"record":{"id":"cbcf1082b676841d","repo":"GoogleContainerTools/skaffold","slug":"creating-container-in-local-docker","errorCode":null,"errorMessage":"creating container in local docker","messagePattern":"creating container in local docker","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/actions/docker/task.go","lineNumber":99,"sourceCode":"\t\texecEnv:     execEnv,\n\t}\n}\n\nfunc (t Task) Name() string {\n\treturn t.name\n}\n\nfunc (t Task) Exec(ctx context.Context, out io.Writer) error {\n\tcn := t.containerName(ctx, t.cfg.Name)\n\n\topts, err := t.containerCreateOpts(ctx, cn)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tstatusCh, errCh, id, err := t.client.Run(ctx, out, *opts)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"creating container in local docker\")\n\t}\n\n\tt.execEnv.TrackContainerFromBuild(graph.Artifact{\n\t\tImageName: t.cfg.Name,\n\t\tTag:       t.cfg.Name,\n\t}, id, cn)\n\n\tvar containerErr error\n\tselect {\n\tcase containerErr = <-errCh:\n\tcase status := <-statusCh:\n\t\tif status.StatusCode != 0 {\n\t\t\tcontainerErr = errors.New(fmt.Sprintf(\"%q running container image %q errored during run with status code: %d\", t.name, opts.ContainerConfig.Image, status.StatusCode))\n\t\t}\n\tcase <-ctx.Done():\n\t\tcontainerErr = ctx.Err()\n\t\tif err := t.client.Stop(context.TODO(), id, util.Ptr(time.Second*0)); err != nil {\n\t\t\tcontainerErr = err","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/actions/docker/task.go#L81-L117","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\ntask, _ := NewTask(cfg, env); err := task.Exec(ctx, out)\n// after\nif _, _, err := exec.Command(\"docker\", \"image\", \"inspect\", cfg.Name).Run(); err != nil {\n    return fmt.Errorf(\"image %s not in local docker; build it first\", cfg.Name)\n}\nif err := task.Exec(ctx, out); err != nil { return err }","handlingStrategy":"validation","validationCode":"// pre-flight before Exec\nif err := exec.Command(\"docker\", \"image\", \"inspect\", cfg.Name).Run(); err != nil {\n    return fmt.Errorf(\"image %s missing from local docker\", cfg.Name)\n}\nif err := exec.Command(\"docker\", \"info\").Run(); err != nil {\n    return errors.New(\"docker daemon not reachable\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["docker","containers","skaffold","local-run"],"backgroundTag":"docker-container-create-failed","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}