slimtoolkit/slim · error

RUN instructions are not supported

Error message

RUN instructions are not supported

What it means

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.

Source

Thrown at pkg/imagebuilder/imagebuilder.go:196

		case instruction.Workdir:
			//options.WorkDir = parts[1]
			options.ImageConfig.Config.WorkingDir = parts[1]
		case instruction.Add:
			//support tar files (ignore other things, at leas, for now)
			//options.Layers []LayerDataInfo
		case instruction.Copy:
			//options.Layers []LayerDataInfo
		case instruction.Maintainer:
			//TBD
		case instruction.Healthcheck:
			//TBD
		case instruction.From:
			//options.From string
		case instruction.Arg:
			//TODO
		case instruction.Run:
			if !ignoreExeInstructions {
				return nil, fmt.Errorf("RUN instructions are not supported")
			}
		case instruction.Onbuild:
			//IGNORE
		case instruction.Shell:
			//IGNORE
		case instruction.StopSignal:
			//IGNORE
		}
	}
	return &options, nil
}

func SimpleBuildOptionsFromDockerfile(path string, ignoreExeInstructions bool) (*SimpleBuildOptions, error) {
	data, err := os.ReadFile(path)
	if err != nil {
		return nil, err
	}

View on GitHub (pinned to 81940d17fa)

Solutions

  1. Set ignoreExeInstructions=true when calling SimpleBuildOptionsFromDockerfile so RUN lines are skipped instead of rejected.
  2. Remove RUN instructions from the Dockerfile and pre-build artifacts outside the image builder, referencing only finished files via COPY-less static layers.
  3. 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).

Example fix

// before
opts, err := imagebuilder.SimpleBuildOptionsFromDockerfile(dockerfileData, name)
// after
ignoreExe := true
opts, err := imagebuilder.SimpleBuildOptionsFromDockerfile(dockerfileData, name, ignoreExe)
Defensive patterns

Strategy: validation

Validate before calling

import "strings"

func dockerfileHasRun(data string) bool {
	for _, line := range strings.Split(data, "\n") {
		t := strings.TrimSpace(line)
		if strings.HasPrefix(t, "#") || t == "" {
			continue
		}
		if strings.HasPrefix(strings.ToUpper(t), "RUN ") || t == "RUN" {
			return true
		}
	}
	return false
}

if dockerfileHasRun(dockerfileData) {
	ignoreExeInstructions = true // or strip RUN lines first
}
opts, err := imagebuilder.SimpleBuildOptionsFromDockerfile(dockerfileData, name, ignoreExeInstructions)

Try / catch

opts, err := imagebuilder.SimpleBuildOptionsFromDockerfile(data, name)
if err != nil && strings.Contains(err.Error(), "RUN instructions are not supported") {
	opts, err = imagebuilder.SimpleBuildOptionsFromDockerfile(data, name, true)
}
if err != nil { return err }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31). Data as JSON: /api/errors/3875ea9fe0773c0b. Report an issue: GitHub.