Repository navigation
Latest 3.10-slim-bullseye fails on Macbook M1 with Rosetta emulation #792
Description
Description
I am using Python image with amd64 platform flag on an arm64 host with a recent experimental feature from Docker : Rosetta emulation.
Recents changes #785 and #790 appear to have broken latest 3.10-slim-bullseye tag
Steps to reproduce
- Activate "Rosetta for x86/amd64 emulation on Apple Silicon" (available from Docker desktop version 4.16)
- Get the Dockerfile written below
docker build .
# Tag used : python:3.10-slim-bullseye
# Last week digest (prior to #785 and #790) : this is working fine
FROM --platform=linux/amd64 python@sha256:3ec369a5db9693672a61f0631a980e66eb6d161f206afa7c9c18237adac466f5
RUN python --version
# Latest digest : this one breaks for me at the moment
FROM --platform=linux/amd64 python@sha256:3ec369a5db9693672a61f0631a980e66eb6d161f206afa7c9c18237adac466f5
RUN python --versionOutput from docker build
[+] Building 1.6s (5/5) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 342B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/python@sha256:e04bc5390a13e6e910980715f1156552fbd3deddf7668e1892575989f9504c70 1.2s
=> CACHED [stage-1 1/2] FROM docker.io/library/python@sha256:e04bc5390a13e6e910980715f1156552fbd3deddf7668e1892575989f9504c70 0.0s
=> ERROR [stage-1 2/2] RUN python --version 0.3s
------
> [stage-1 2/2] RUN python --version:
#5 0.278 rosetta error: failed to open elf at
#5 0.279 Trace/breakpoint trap
------
executor failed running [/bin/sh -c python --version]: exit code: 133
docker info
Details
Client: Context: default Debug Mode: false Plugins: buildx: Docker Buildx (Docker Inc., v0.10.0) compose: Docker Compose (Docker Inc., v2.15.1) dev: Docker Dev Environments (Docker Inc., v0.0.5) extension: Manages Docker extensions (Docker Inc., v0.2.17) sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0) scan: Docker Scan (Docker Inc., v0.23.0)Server:
Containers: 56
Running: 0
Paused: 0
Stopped: 56
Images: 139
Server Version: 20.10.22
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9ba4b250366a5ddde94bb7c9d1def331423aa323
runc version: v1.1.4-0-g5fd4c4d
init version: de40ad0
Security Options:
seccomp
Profile: default
cgroupns
Kernel Version: 5.15.49-linuxkit
Operating System: Docker Desktop
OSType: linux
Architecture: aarch64
CPUs: 5
Total Memory: 7.667GiB
Name: docker-desktop
ID: S7XT:BZCS:DMNP:2TAA:PFBH:7PU4:CKGN:MNJW:CWHQ:U6RS:VLO2:UXQI
Docker Root Dir: /var/lib/docker
Debug Mode: false
HTTP Proxy: http.docker.internal:3128
HTTPS Proxy: http.docker.internal:3128
No Proxy: hubproxy.docker.internal
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
hubproxy.docker.internal:5000
127.0.0.0/8
Live Restore Enabled: false
Activity
tianon commentedon Jan 25, 2023
We're setting
rpathcorrectly (and very conservatively), so this is definitely going to be a bug in Rosetta's parsing of the ELF binary. 😞jimnicholls commentedon Jan 26, 2023
This is not just 3.10-slim-bullseye. It happens for alpine, non-slim and different Python versions.
The
¿is actually code point 007F.Sometimes I get a seg fault instead of a rosetta error.
tianon commentedon Jan 26, 2023
I can't reproduce with QEMU's emulation, so this has to be a bug in Rosetta -- does anyone know where would be an appropriate place to raise/file that?
rik commentedon Jan 27, 2023
Before sending feedback to Apple, I think there's one more test to do: execute an x86_64 binary with similar modifications directly on an ARM-based Mac, without Docker.
If that test passes then it may be a Docker issue or a Virtualization.framework issue. If that test fails, it is a Rosetta issue.
(This is not my area of expertise at all so I have no idea how to do that)
How to send Apple feedback
jimnicholls commentedon Jan 27, 2023
Nice idea @rik. Unfortunately macOS doesn't use ELF. It uses the Mach-O format1.
It turns out what I was seeing in the Rosetta error message was the first four bytes of an ELF, which are the ELF magic number
0x7F E L F. 3.Footnotes
https://en.wikipedia.org/wiki/Mach-O ↩
https://en.wikipedia.org/wiki/Rosetta_(software)#Rosetta_2 ↩
https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header ↩
jimnicholls commentedon Jan 27, 2023
Using
patchelfto set and then remove the rpath triggers this issue.patchelfseems to be make substantial changes to the ELF, particularly the program headers. Even hello world breaks afterpatchelf.Dockerfile
docker buildx build --platform=linux/amd64 --progress=plain .
rik commentedon Feb 4, 2023
@jimnicholls Thank you very much for working on this. I've just confirmed it fixed the issue for me with the latest tag.