{"record":{"id":"940c6c57ca02af04","repo":"wagoodman/dive","slug":"cannot-build-image-w","errorCode":null,"errorMessage":"cannot build image: %w","messagePattern":"cannot build image: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"cmd/dive/cli/internal/command/build.go","lineNumber":40,"sourceCode":"\treturn app.SetupCommand(&cobra.Command{\n\t\tUse:                \"build [any valid `docker build` arguments]\",\n\t\tShort:              \"Builds and analyzes a docker image from a Dockerfile (this is a thin wrapper for the `docker build` command).\",\n\t\tDisableFlagParsing: true,\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tif err := setUI(app, opts.Application); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to set UI: %w\", err)\n\t\t\t}\n\n\t\t\tresolver, err := dive.GetImageResolver(opts.Analysis.Source)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"cannot determine image provider for build: %w\", err)\n\t\t\t}\n\n\t\t\tctx := cmd.Context()\n\n\t\t\timg, err := adapter.ImageResolver(resolver).Build(ctx, args)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"cannot build image: %w\", err)\n\t\t\t}\n\n\t\t\treturn run(cmd.Context(), opts.Application, img, resolver)\n\t\t},\n\t}, opts)\n}\n","sourceCodeStart":22,"sourceCodeEnd":47,"githubUrl":"https://github.com/wagoodman/dive/blob/d6c691947f8fda635c952a17ee3b7555379d58f0/cmd/dive/cli/internal/command/build.go#L22-L47","documentation":"Returned by `dive build` when the underlying container engine fails to build the image from the given Dockerfile arguments. dive build is a thin wrapper over docker/podman build: the args slice is forwarded verbatim, so this error wraps whatever the engine's build API returned — Dockerfile syntax errors, missing build context, failed RUN steps, network failures during pulls.","triggerScenarios":"adapter.ImageResolver(resolver).Build(ctx, args) with args like '.' pointing at a context with a broken Dockerfile; RUN steps that exit non-zero; FROM referencing an untaggable/unpullable image; invalid flags passed through because DisableFlagParsing is set.","commonSituations":"Running dive build . on a Dockerfile that does not yet build cleanly; CI checkout missing the build context directory; a base image pull failing behind a corporate proxy; passing docker build flags dive forwards verbatim.","solutions":["Read the wrapped error — it contains the engine's own build log line that failed","Reproduce outside dive first (docker build <same args>) and fix the Dockerfile/step it points to","Verify the build context path and Dockerfile name match what you passed","Fix network/registry access if the failure is a base-image pull (proxy, auth via docker login)"],"exampleFix":"# before\nFROM alpine\nRUN exit 1   # dive build fails here\n\n# after\nFROM alpine\nRUN echo ok","handlingStrategy":"try-catch","validationCode":"# validate the build works before wrapping it with dive\ndocker build -t probe/context . || exit 1   # cheap pre-check\ndive build .","typeGuard":null,"tryCatchPattern":"img, err := adapter.ImageResolver(resolver).Build(ctx, args)\nif err != nil {\n    // wrapped text contains the engine's own failing step; surface it verbatim for the user\n    return fmt.Errorf(\"cannot build image: %w\", err)\n}","preventionTips":["Keep the Dockerfile building cleanly with plain docker build before adding dive","Pass a context path explicitly instead of relying on cwd","Run base-image pulls (docker pull) ahead of dive build in flaky-network environments"],"tags":["build","dockerfile","docker","podman","engine"],"backgroundTag":null,"analyzedSha":"d6c691947f8fda635c952a17ee3b7555379d58f0","analyzedAt":"2026-08-15T09:42:35.293Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}