{"record":{"id":"47adedc096ec2567","repo":"GoogleContainerTools/skaffold","slug":"creating-container-in-local-docker-47aded","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/deploy/docker/deploy.go","lineNumber":215,"sourceCode":"\t\tvar mounts []mount.Mount\n\t\tfor _, m := range d.debugger.SupportMounts() {\n\t\t\tmounts = append(mounts, m)\n\t\t}\n\t\topts.Mounts = mounts\n\t}\n\n\t// Filter for the port resource for the given artifact.ImageName\n\tfilteredPFResources := d.filterPortForwardingResources(artifact.ImageName)\n\n\tbindings, err := d.portManager.AllocatePorts(artifact.ImageName, filteredPFResources, containerCfg, debugBindings)\n\tif err != nil {\n\t\treturn err\n\t}\n\topts.Bindings = bindings\n\n\t_, _, id, err := d.client.Run(ctx, out, opts)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"creating container in local docker\")\n\t}\n\td.TrackContainerFromBuild(artifact, tracker.Container{Name: containerName, ID: id})\n\treturn nil\n}\n\nfunc (d *Deployer) filterPortForwardingResources(imageName string) []*latest.PortForwardResource {\n\tfilteredPFResources := []*latest.PortForwardResource{}\n\tfor _, p := range d.resources {\n\t\tif strings.EqualFold(imageName, p.Name) {\n\t\t\tfilteredPFResources = append(filteredPFResources, p)\n\t\t}\n\t}\n\treturn filteredPFResources\n}\n\n// setupDebugging configures the provided artifact's image for debugging (if applicable).\n// The provided container configuration receives any relevant modifications (e.g. ENTRYPOINT, CMD),\n// and any init containers for populating the shared debug volume will be created.","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/deploy/docker/deploy.go#L197-L233","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the image exists locally (`docker image inspect <artifact>`) or load/pull it before deploy.","Confirm docker daemon is reachable (`docker info`) and socket permissions are correct.","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.","If the deployment may have left state, clean up leftovers (`docker ps -a --filter name=<name>`) before retrying.","Ensure the docker context matches the environment where images were built."],"exampleFix":"// before\nskaffold deploy -d images && ...\n// after\ndocker image inspect my-image || skaffold build\nskaffold deploy","handlingStrategy":"validation","validationCode":"// pre-flight: image exists and daemon is healthy\nif err := exec.Command(\"docker\", \"image\", \"inspect\", artifact).Run(); err != nil {\n    return fmt.Errorf(\"image %s not in local docker; run skaffold build first\", artifact)\n}\nif err := exec.Command(\"docker\", \"info\").Run(); err != nil {\n    return errors.New(\"docker daemon not reachable\")\n}","typeGuard":null,"tryCatchPattern":"// Go\nif _, _, _, err := d.client.Run(ctx, out, opts); err != nil {\n    werr := errors.Wrap(err, \"creating container in local docker\")\n    // check root cause\n    if strings.Contains(err.Error(), \"port is already allocated\") { /* remap ports */ }\n    if strings.Contains(err.Error(), \"name already in use\") { /* rm leftover */ }\n    return werr\n}","preventionTips":["Run skaffold build (same daemon) before skaffold deploy.","Clean up leftover containers from crashed runs.","Avoid fixed host port bindings that can collide."],"tags":["docker","containers","skaffold","deploy"],"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"}