{"record":{"id":"3875ea9fe0773c0b","repo":"slimtoolkit/slim","slug":"run-instructions-are-not-supported","errorCode":null,"errorMessage":"RUN instructions are not supported","messagePattern":"RUN instructions are not supported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/imagebuilder/imagebuilder.go","lineNumber":196,"sourceCode":"\t\tcase instruction.Workdir:\n\t\t\t//options.WorkDir = parts[1]\n\t\t\toptions.ImageConfig.Config.WorkingDir = parts[1]\n\t\tcase instruction.Add:\n\t\t\t//support tar files (ignore other things, at leas, for now)\n\t\t\t//options.Layers []LayerDataInfo\n\t\tcase instruction.Copy:\n\t\t\t//options.Layers []LayerDataInfo\n\t\tcase instruction.Maintainer:\n\t\t\t//TBD\n\t\tcase instruction.Healthcheck:\n\t\t\t//TBD\n\t\tcase instruction.From:\n\t\t\t//options.From string\n\t\tcase instruction.Arg:\n\t\t\t//TODO\n\t\tcase instruction.Run:\n\t\t\tif !ignoreExeInstructions {\n\t\t\t\treturn nil, fmt.Errorf(\"RUN instructions are not supported\")\n\t\t\t}\n\t\tcase instruction.Onbuild:\n\t\t\t//IGNORE\n\t\tcase instruction.Shell:\n\t\t\t//IGNORE\n\t\tcase instruction.StopSignal:\n\t\t\t//IGNORE\n\t\t}\n\t}\n\treturn &options, nil\n}\n\nfunc SimpleBuildOptionsFromDockerfile(path string, ignoreExeInstructions bool) (*SimpleBuildOptions, error) {\n\tdata, err := os.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/imagebuilder/imagebuilder.go#L178-L214","documentation":"SimpleBuildOptionsFromDockerfileData parses Dockerfile instructions into simple build options. RUN instructions would require executing commands during the image build; unless the caller sets ignoreExeInstructions, the parser rejects them outright because this builder only supports static/metadata-only Dockerfiles.","triggerScenarios":"Passing Dockerfile content containing 'RUN ...' lines to SimpleBuildOptionsFromDockerfile(SimpleBuildOptionsFromDockerfileData) with ignoreExeInstructions=false (the default). Any Dockerfile that installs packages, compiles code, or runs scripts triggers this.","commonSituations":"Reusing an existing application Dockerfile (which almost always has RUN apt-get install / RUN go build) for a metadata-only build; forgetting to pass the ignore-exe-instructions option; accidentally leaving a RUN line in a generated Dockerfile.","solutions":["Set ignoreExeInstructions=true when calling SimpleBuildOptionsFromDockerfile so RUN lines are skipped instead of rejected.","Remove RUN instructions from the Dockerfile and pre-build artifacts outside the image builder, referencing only finished files via COPY-less static layers.","Split the Dockerfile: keep RUN steps in a normal Docker build pipeline and hand the builder a minimal FROM-only Dockerfile with metadata (ENV, ENTRYPOINT, CMD)."],"exampleFix":"// before\nopts, err := imagebuilder.SimpleBuildOptionsFromDockerfile(dockerfileData, name)\n// after\nignoreExe := true\nopts, err := imagebuilder.SimpleBuildOptionsFromDockerfile(dockerfileData, name, ignoreExe)","handlingStrategy":"validation","validationCode":"import \"strings\"\n\nfunc dockerfileHasRun(data string) bool {\n\tfor _, line := range strings.Split(data, \"\\n\") {\n\t\tt := strings.TrimSpace(line)\n\t\tif strings.HasPrefix(t, \"#\") || t == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tif strings.HasPrefix(strings.ToUpper(t), \"RUN \") || t == \"RUN\" {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nif dockerfileHasRun(dockerfileData) {\n\tignoreExeInstructions = true // or strip RUN lines first\n}\nopts, err := imagebuilder.SimpleBuildOptionsFromDockerfile(dockerfileData, name, ignoreExeInstructions)","typeGuard":null,"tryCatchPattern":"opts, err := imagebuilder.SimpleBuildOptionsFromDockerfile(data, name)\nif err != nil && strings.Contains(err.Error(), \"RUN instructions are not supported\") {\n\topts, err = imagebuilder.SimpleBuildOptionsFromDockerfile(data, name, true)\n}\nif err != nil { return err }","preventionTips":["Scan Dockerfiles for RUN before handing them to the metadata-only parser","Keep two Dockerfile variants: full build vs static image definition","Always pass ignoreExeInstructions explicitly to document intent","Pre-build artifacts outside the builder and reference them statically"],"tags":["docker","image-builder","dockerfile","build"],"backgroundTag":"unsupported-dockerfile-instruction","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}