skip to Main Content

I have an application I run on Docker which works fine on my older intel-based Mac. However, on the M1 Mac, I get pip install errors when running docker-compose up. e.g

 asyncpg==0.24.0
 error: command 'gcc' failed: No such file or directory

My Dockerfile uses python-slim which has no compiler, so I understand why:

FROM python:3.10-slim

WORKDIR /src
COPY . ./
RUN pip install --upgrade pip
RUN pip install -r requirements.txt

I’d like to stick to the -slim package. What is the best way to make this work on the Mac M1?

Thanks!

2

Answers


  1. You can install missing packages like this on a Debian image. I’ve had the same issue in the past with the normal Postgres adapter.

    RUN apt-get update && apt-get install -y gcc
    

    Make sure to put it before your pip install RUN directives.

    Login or Signup to reply.
  2. I had a similar issue and forcing the platform to linux/amd64 fixed it:

    FROM --platform=linux/amd64 python:3.10-slim
    

    See known issues:

    Not all images are available for ARM64 architecture. You can add --platform linux/amd64 to run an Intel image under emulation.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search