Docker and Apple M1

A curious incident led to a study of the compatibility of the Apple M1 processor, and it turned out that not everything is so simple …

However, first things first. A colleague of mine who owns a MacBook Pro with M1 asked me to help with the installation libraries

I have almost the same MacBook, but on Intel Core i5, macOS Big Sur. When trying to install the library

pip install qvd

ERROR: Could not find a version that satisfies the requirement qvd (from versions: none)

ERROR: No matching distribution found for qvd

This usually happens when the package contains a module that is incompatible with the current OS. In such a situation, the first thing I do is try to install the library in the docker container, where I have a very wide choice of possible OS and settings.

Dockerfile:

FROM python:3.8-slim-buster

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

COPY . /app
WORKDIR /app

RUN pip install --upgrade pip
RUN pip install -r requirements.txt

CMD ["python", "main.py"]

requirements.txt:

qvd==0.0.10

main.py:

import qvd


if __name__ == '__main__':
  print('Hello, qvd')

Then we execute the command:

docker build -t testqvd: latest.

And oops, everything works, the library gets up, the image is built, the container is launched:

docker run testqvd

Hello, qvd

I will add (not related to this topic) that the library works for real, I connected real files and processed them with this library.

I give the project to a colleague, but he is not going to!

docker -v

Docker version 20.10.7, build f0df350

We both have the same docker version. What could be the reason? After all, the execution of the code from the Dockerfile actually goes in the python image: 3.8-slim-buster, it is the same here. We need to dive deeper, deal with pip

First, let’s see why qvd is not installed on Big Sur:

pip install -vvv qvd

This command displays a lot of text, but the main thing that is understandable is none of the wheel’s tags (cp37-none-win_amd64) are compatible (run pip debug –verbose to show compatible tags), there are a lot of such lines and among them there are only win and manylinux.

Let’s run

pip debug –verbose

and get a list of matching pip tags. Of course, there is no win, but there is py32-none-macosx_10_13_x86_64 (and similar). All those who are interested in what this means I refer here: https://github.com/pypa/manylinux

Compatibility tags don’t match, probably for good reason – there are libraries that won’t run on Big Sur. OK, of course, there are no questions, but there are questions why there is such a significant difference when building an image on the same OS from the same source.

I add the line to the Dockerfile:

FROM python:3.8-slim-buster

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

COPY . /app
WORKDIR /app

RUN pip install --upgrade pip
RUN pip debug --verbose > /tmp/pip.txt
RUN pip install -r requirements.txt

CMD ["python", "main.py"]

and start the build with the following command:

docker build -t testqvd: latest -o / tmp / buildlogs

As a result, I get the file /tmp/buildlogs/tmp/pip.txt with the results of pip tags during build. My colleague does the same. And they (tags) turn out to be different, for me, for example, – py38-none-manylinux_2_16_x86_64, from a colleague py37-none-manylinux_2_28_aarch64

So, the M1 processor (obviously) does not coincide with Intel Core and no clever docker – technologies can not fix anything. I will be wary of switching to M1 for now and would advise against other developers.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *