{"record":{"id":"49c804ee30c09c6d","repo":"GoogleContainerTools/skaffold","slug":"inspecting-init-container","errorCode":null,"errorMessage":"inspecting init container","messagePattern":"inspecting init container","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/deploy/docker/deploy.go","lineNumber":286,"sourceCode":"\t\t})\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tm := d.createMount(v, labels)\n\n\t\t// create the init container\n\t\tc.Labels = labels\n\t\t_, _, id, err := d.client.Run(ctx, out, dockerutil.ContainerCreateOpts{\n\t\t\tContainerConfig: c,\n\t\t\tMounts:          []mount.Mount{m},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"creating container in local docker\")\n\t\t}\n\t\tr, err := d.client.ContainerInspect(ctx, id)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"inspecting init container\")\n\t\t}\n\t\tif len(r.Mounts) != 1 {\n\t\t\tolog.Entry(ctx).Warnf(\"unable to retrieve mount from debug init container: debugging may not work correctly!\")\n\t\t}\n\t\t// we know there is only one mount point, since we generated the init container config ourselves\n\t\td.debugger.AddSupportMount(c.Image, m)\n\t}\n\n\tbindings := make(network.PortMap)\n\tconfig := d.debugger.ConfigurationForImage(containerCfg.Image)\n\tfor _, port := range config.Ports {\n\t\tp, err := network.ParsePort(fmt.Sprint(port) + \"/tcp\")\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tbindings[p] = []network.PortBinding{\n\t\t\t{HostIP: netip.MustParseAddr(\"127.0.0.1\"), HostPort: fmt.Sprint(port)},\n\t\t}","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/deploy/docker/deploy.go#L268-L304","documentation":"Immediately after creating a debug init container, Skaffold inspects it with d.client.ContainerInspect to discover its mounts (it expects exactly one, the shared debug volume). If the inspect call itself fails — container removed, daemon error, connection lost — the error is wrapped with this message.","triggerScenarios":"setupDebugging calls d.client.ContainerInspect(ctx, id) right after a successful container create; inspect fails because the container exited/was auto-removed, the daemon restarted between create and inspect, or the Docker API connection dropped.","commonSituations":"An `--rm`-like auto-removal or a competing cleanup deleting the container between create and inspect; Docker daemon crash/restart mid-deploy; very short-lived init container removed by another skaffold process.","solutions":["Retry `skaffold debug` — often transient (daemon restart or racing cleanup)","Check `docker events`/daemon logs around the failure time to see why the container vanished","Ensure only one skaffold process manages the deployment (concurrent runs delete each other's containers)","Verify daemon stability: `docker info` and Docker Desktop/colima health","If reproducible, capture the wrapped inspect error and file it with `skaffold diagnose` output"],"exampleFix":"// before\nerror: inspecting init container: Error: No such container: <id>\n// after\n$ skaffold delete\n$ skaffold debug   # single clean run, no concurrent skaffold processes","handlingStrategy":"retry","validationCode":"null","typeGuard":"null","tryCatchPattern":"if err := deploy(ctx); err != nil && strings.Contains(err.Error(), \"inspecting init container\") {\n  log.Printf(\"transient inspect failure (%v); retrying once\", err)\n  err = deploy(ctx)\n}","preventionTips":["Run only one skaffold process per daemon to avoid racing cleanups","Keep the Docker daemon from auto-restarting mid-deploy (disable aggressive Docker Desktop restarts)","Check daemon logs if failures recur","Retry the deploy — inspect failures right after create are usually transient"],"tags":["docker","container-inspect","debug","race"],"backgroundTag":"container-not-found","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"}