Software⏱️ 2 min read📅 2026-06-03

How to Fix: Docker : exec /usr/bin/sh: exec format error

Docker exec format error in CI/CD pipeline

Quick Answer: The issue is likely due to the Docker image not being compatible with the Python version installed. Try using a different base image that supports Python 3, such as Ubuntu:20.04-buster or Ubuntu:20.04-focal.

The Docker exec format error occurs when the system is unable to determine the correct format of an executable file. In this case, the issue arises from the fact that the Docker image uses a different format for the shell than the one used in the CI/CD pipeline.

🛑 Root Causes of the Error

  • The Docker image uses a different format for the shell than the one used in the CI/CD pipeline.

🛠️ Step-by-Step Verified Fixes

Method 1: Change the Shell Format in Dockerfile

  1. Step 1: Update the Dockerfile to use a specific shell format, such as '/bin/sh' instead of 'sh'. The updated Dockerfile would look like this:

Updated Dockerfile

FROM ubuntu:20.04
/bin/sh -c

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions