Contained command cannot be invoked
This exit code signifies that the command specified in the container's CMD or ENTRYPOINT could not be executed because it lacks execute permissions. It's a file system permission issue within the container image itself.
- 1The script or binary specified as the container's entrypoint does not have the execute bit (+x) set.
- 2The file system was mounted with the 'noexec' option, preventing execution of any binaries.
- 3The script has the wrong shebang line (e.g., `#!/bin/sh ` with Windows line endings).
- 4The binary is compiled for the wrong architecture (e.g., ARM binary on an x86 host).
A Dockerfile copies a shell script but fails to give it execute permissions.
# Dockerfile FROM alpine WORKDIR /app COPY start.sh . # Missing: RUN chmod +x start.sh ENTRYPOINT ["./start.sh"] # start.sh (without execute permission) #!/bin/sh echo "Hello, World!"
expected output
OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "./start.sh": permission denied: unknown
Fix 1
Add Execute Permissions in Dockerfile
WHEN When the entrypoint is a script you control.
# Add this layer to your Dockerfile before the CMD or ENTRYPOINT RUN chmod +x your-script.sh
Why this works
This sets the execute bit for the script within the image file system, making it runnable.
Fix 2
Use 'sh' to Run the Script
WHEN You cannot modify the Dockerfile or file permissions easily.
# Modify the ENTRYPOINT or docker run command ENTRYPOINT ["sh", "./your-script.sh"]
Why this works
This invokes the shell ('sh') executable, which is runnable, and instructs it to interpret and execute your script, bypassing the script's own execute permission.
✕ Set 'chmod 777' on all files.
This makes files world-writable, creating a security vulnerability. Only grant the minimum required permissions (e.g., 'chmod +x' or 'chmod 755').
Linux man-pages: execve(2)
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev