Error: exec /usr/local/bin/docker-entrypoint.sh: exec format error
Root Causes:
Wrong Architecture (ARM vs x86):
The container image was built for a different architecture than the node it’s running on.
For example, the image is ARM64, but your Kubernetes nodes are x86_64 (or vice versa).
Corrupted or Invalid Script File:
The entrypoint script is missing a shebang (#!/bin/sh), or it's in Windows format (CRLF line endings) instead of Unix (LF).
How to Fix:
Alternative Quick Fix (One-Time Use)
If you want to avoid editing the compose.yaml, just build like this:
DOCKER_DEFAULT_PLATFORM=linux/amd64 docker compose build --no-cache
Fix: Force the Build to Use x86_64
To make sure your image is compatible with your cluster (which is almost certainly x86_64), you just need to add the platform flag.
Here’s how:
Option 1: Add platform to docker-compose.yml
In your docker-compose.yml, add the following under the service that builds your Python image:
services:
your-service-name:
build:
context: .
dockerfile: Dockerfile
platform: linux/amd64
Tags:
Blog
