Docker Exit Code 126: Permission Problem Fix

Symptom

Container exits instantly with code 126.

Root cause

The command inside the image exists but is not executable by that user.

Fix, in order

1. Inspect the entrypoint bitdocker run --rm <image> ls -la /entrypoint.sh
2. Fix the exec bit at build timeRUN chmod +x /entrypoint.sh
3. Confirm the shebang is righthead -1 /entrypoint.sh # #!/bin/sh or #!/bin/bash

Prevent it coming back

Set the exec bit in the Dockerfile, not in CI tricks.

Run it on clean infra

Spinning up a fresh box to reproduce or escape this error?

DevOps tools shelf

Related

Cloud & DevOps tool comparisons · Hardware build guides

NinjaOps publishes free engineering guides. Some outbound links are affiliate links: they cost you nothing and support the site.

Last reviewed 2026-10-02 · NinjaOps SEO grid · DevOps blog