Dockerfile RUN "not found" exit code 127 in CI
A RUN step called a command the shell could not find, so it exited 127. The tool is not installed in this stage, is in a different stage, or the name is misspelled.
What this error means
A RUN step prints "/bin/sh: 1: yarn: not found" (Debian dash) or "yarn: command not found" (bash), then the build summary shows exit code 127.
/bin/sh: 1: yarn: not found
ERROR: failed to solve: process "/bin/sh -c yarn install" did not complete successfully: exit code: 127Common causes
The tool is not installed in this stage
The package providing the command was never installed, or it was installed in a different build stage that this one does not inherit.
A typo or wrong PATH
A misspelled command, or a binary installed to a directory not on PATH, both surface as "not found" with exit 127.
How to fix it
Install the tool in the same stage
Add the package that provides the command before you call it.
RUN apt-get update && apt-get install -y --no-install-recommends git \
&& rm -rf /var/lib/apt/lists/*
RUN git --versionCheck the name and PATH
- Confirm the exact command name and spelling.
- Verify the install directory is on PATH in this stage.
- For Alpine, install with
apk addrather thanapt-get.
How to prevent it
- Install required tools in the stage that uses them.
- Verify command names and PATH before relying on them.
- Remember exit 127 specifically means command-not-found.