M1 Pro device: problems with docker compose

During the last days I was trying to run dockerized projects on MacBook Pro with an Apple silicon – M1 Pro processor. I was using docker compose and encountered a few problems during this process.

In the problematic project I have two Dockerfiles. One is based on python:3.8.5-slim image and the second one on node:12 image.

I encountered problems in both, backend (python based) and frontend (node based) images.

I made a few steps to make things working (I don’t mention everything and please do not follow now. TL;DR below):

  1. updated pip while building the image, so I added RUN pip install --upgrade pip line before installing python dependencies
  2. updated versions number of a few project dependencies. Just to mention that psycopg2-binary==2.8.4 was problematic and psycopg2-binary==2.9.3 started working properly
  3. I also had to add g++ to my RUN apt-get install -y line.
  4. I also had a problem with frontend image, but fixing one problem caused another with gulp-imagemin. I reported it here: https://github.com/sindresorhus/gulp-imagemin/issues/369
TL;DR

Today I found the solution here (https://github.com/docker/for-mac/issues/5419) that allows me to run and build my app without any problems and changes mentioned above*. The only thing I had to change was adding --platform=linux/amd64, so changing lines:

FROM python:3.8.5-slim
FROM node:12

to:

FROM --platform=linux/amd64 python:3.8.5-slim
FROM --platform=linux/amd64 node:12

I hope it could save you a day too. Let me know if it works on your machine!

_______________
* ok, there’s still a problem with one my minor dependencies when running the app. I reported it here https://github.com/Pylons/pyramid_openapi3/issues/160 , but beside of this the solution works.

Leave a comment

Your email address will not be published.