exec: 'command': executable file not found in $PATH
exec: 'command': executable file not found in $PATH
DodaTech
2 min read
The error “exec: ‘command’: executable file not found in $PATH” occurs during a RUN instruction in a Dockerfile when the specified command is not available inside the container image.
What It Means
Docker builds each layer by running a command in a temporary container based on the previous layer. When a RUN instruction references a command that is not installed in the container, the shell or exec form returns this error and the build fails immediately.
Why It Happens
- The base image is minimal (e.g.,
alpine,scratch,distroless) and does not include common tools. - The command name is misspelled or the wrong package provides it.
- The
RUNinstruction appears before the package install command. - The command was installed in a previous
RUNbut the image was cached and the cache was invalidated. - The exec form (
RUN ["command", "arg"]) is used but the command is not inPATH.
How to Fix It
1. Use the exec form with the full path
RUN ["/usr/bin/curl", "-sL", "https://example.com"]2. Install the missing package
RUN apt-get update && apt-get install -y curl3. For Alpine, use apk
RUN apk add --no-cache curl4. Check what is in the base image
RUN which command_name # debug: see if it exists5. Combine RUN instructions to avoid ordering issues
RUN apt-get update && apt-get install -y \
curl \
git \
&& rm -rf /var/lib/apt/lists/*FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro