Skip to content

exec format error on M4 Macbook #1113

@mattmacf98

Description

@mattmacf98

I have an M4 macbook air and am trying to use python:3.11-slim as my base here is my Dockerfile below

FROM python:3.11-slim

WORKDIR /app


# Install dependencies with uv (parallel downloads, uses pre-built wheels)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy application
COPY app.py .

# Expose the sidecar port
EXPOSE 7778

# Bind to 0.0.0.0 so the server is reachable from outside the container
ENV FLASK_APP=app.py
CMD ["flask", "run", "--host=0.0.0.0", "--port=7778"]

running this fails at pip install

 => [internal] load build definition from Dockerfile                                             0.0s
 => => transferring dockerfile: 448B                                                             0.0s
 => [internal] load metadata for docker.io/library/python:3.11-slim                              0.5s
 => [auth] library/python:pull token for registry-1.docker.io                                    0.0s
 => [internal] load .dockerignore                                                                0.0s
 => => transferring context: 2B                                                                  0.0s
 => [1/5] FROM docker.io/library/python:3.11-slim@sha256:d6e4d224f70f9e0172a06a3a2eba2f768eb146  0.0s
 => => resolve docker.io/library/python:3.11-slim@sha256:d6e4d224f70f9e0172a06a3a2eba2f768eb146  0.0s
 => [internal] load build context                                                                0.0s
 => => transferring context: 63B                                                                 0.0s
 => CACHED [2/5] WORKDIR /app                                                                    0.0s
 => CACHED [3/5] COPY requirements.txt .                                                         0.0s
 => ERROR [4/5] RUN pip install --no-cache-dir -r requirements.txt                               0.1s
------                                                                                                
 > [4/5] RUN pip install --no-cache-dir -r requirements.txt:
0.106 exec /bin/sh: exec format error
------
Dockerfile:8
--------------------
   6 |     # Install dependencies with uv (parallel downloads, uses pre-built wheels)
   7 |     COPY requirements.txt .
   8 | >>> RUN pip install --no-cache-dir -r requirements.txt
   9 |     
  10 |     # Copy application
--------------------
ERROR: failed to build: failed to solve: process "/bin/sh -c pip install --no-cache-dir -r requirements.txt" did not complete successfully: exit code: 255

if I swap the FROM to

FROM --platform=linux/amd64 python:3.11-slim then it builds (but with emulation which is not ideal)

System info:
Macbook air M4, 2025, macOS Sequoia 15.3

Thank you in advance if anyone has a fix for this!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions