Skip to main content

Command Palette

Search for a command to run...

Build AMD64 Docker on M1

Published
2 min read

I plan to verify 0-RTT capability using sslyze as mentioned in here on M1:

python -m sslyze --early_data www.fastly.com

I got below error:

ImportError: dlopen(/Users/gu/.pyenv/versions/3.10.1/lib/python3.10/site-packages/nassl/_nassl.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '_PEM_write_bio_X509'

It happens because on my Mac M1, installed Python tool-chain is built in ARM64 and one required package has no ARM64 build. This error is mentioned in this post, and one commented:

I’m just going to use docker containers for my development purposes instead of messing with dual installations of homebrew/python

This is how to build a docker container of AMD64 architecture Python environment (if you do not want to use pre-built ones like nablac0d3/sslyze:5.0.0).

Create a requirement.txt to list Python package needed for your environment.

sslyze
requests
# other packages ...

Create a Dockerfile, the first line force the docker to pull an AMD64 image.

FROM --platform=amd64 python:3
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
# un-comment below if needs to run some script
# COPY my_script.py .
# CMD [ "python", "./my_script.py" ]

Build docker image

$ docker build -t python-env .

Start a bash terminal

$ docker run -it python-env bash
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
/usr/src/app#

We get some warning but it can be safely ignored, and we can run sslyze like below

/usr/src/app# python -m sslyze --early_data www.fastly.com

If you do not want to build your own python AMD64 docker image to run sslyze, you can use pre-built one like

docker run --rm -it nablac0d3/sslyze:5.0.0 --early_data www.fastly.com

More from this blog

Dog Tera

7 posts

Cat is a tech blog with has nothing to do with cat.