Docker Command Invocation Error / Permission Denied
This exit code indicates that the command invoked within the Docker container cannot be executed. This often means the command is not found in the container's PATH, is not executable, or there are permission issues preventing its execution.
Common Causes
- The specified command or script does not exist at the given path within the container.
- The command or script does not have execute permissions (e.g., `chmod +x` was not applied).
- The command is not in the container's `PATH` environment variable.
- Incorrect `ENTRYPOINT` or `CMD` syntax in the Dockerfile or `docker run` command.
- Missing dependencies required for the command to run.
How to Fix
1 Verify Command Path and Existence
Ensure the command specified in your Dockerfile's `ENTRYPOINT` or `CMD` (or `docker run` command) actually exists within the container's filesystem and is discoverable via the container's `PATH` environment variable. You can inspect the container or run a temporary command to check.
$ docker exec <container_id_or_name> which <command_name>
docker exec <container_id_or_name> printenv PATH 2 Grant Execute Permissions
If you are trying to execute a script (e.g., a shell script) within the container, ensure it has execute permissions. This is a common oversight when copying scripts into the image.
$ COPY my-script.sh /usr/local/bin/my-script.sh
RUN chmod +x /usr/local/bin/my-script.sh 3 Review Dockerfile ENTRYPOINT/CMD Syntax
Incorrect syntax for `ENTRYPOINT` or `CMD` can lead to the command not being properly invoked. Ensure you are using the exec form (preferred) or shell form correctly, and that the command itself is valid.
$ # Exec form (preferred for ENTRYPOINT)
ENTRYPOINT ["/usr/local/bin/my-script.sh", "--arg1"]
# Shell form (less preferred for ENTRYPOINT, but common for CMD)
CMD /usr/local/bin/my-script.sh --arg1