georiv
georiv

Reputation: 213

Running Docker Containers on Mac Apple Silicon M2: Platform Compatibility and Execution Errors (linux/arm64)

I'm a newbie to both macOS and Docker. I'm running into a series of roadblocks while trying to launch my project using Docker on Apple Silicon M2. I think that the issues i'm facing are related to bad compatibility between the image: webdevops/php-apache-dev:7.2 and the platform i'm using.

My docker-compose.yml looks like this:

version: "3"
services:
  web:
    image: webdevops/php-apache-dev:7.2

Also, i've changed it in some point to add:

version: "3"
services:
  web:
    platform:linux/amd64
    image: webdevops/php-apache-dev:7.2

but keep getting errors.

I don't know what else to try. If you've got any insights or solutions to share, I'd greatly appreciate your guidance!

When I kick off docker-compose up, I'm greeted with an error message inside the my_project container that looks like this:

goroutine 1 [running]:
runtime.systemstack_switch()
    /usr/local/Cellar/go/1.8.1/libexec/src/runtime/asm_amd64.s:281 fp=0xc420028788 sp=0xc420028780
runtime.main()
    /usr/local/Cellar/go/1.8.1/libexec/src/runtime/proc.go:127 +0x6c fp=0xc4200287e0 sp=0xc420028788
runtime.goexit()
    /usr/local/Cellar/go/1.8.1/libexec/src/runtime/asm_amd64.s:2197 +0x1 fp=0xc4200287e8 sp=0xc4200287e0
my_project exited with code 2

In my quest to troubleshoot, I tried adding the platform: linux/amd64 key to the web service in my docker-compose.yml file. However, this led to a different hurdle:

Error response from daemon: image with reference webdevops/php-apache-dev:7.2 was found but does not match the specified platform: wanted linux/arm64/v8, actual: linux/amd64

Switching gears, I experimented with changing the image to webdevops/php-apache-dev:7.4, but this led me to yet another error:

[+] Running 1/1
 ✘ web Error                                                                                                                           20.2s
Error response from daemon: Get "https://registry-1.docker.io/v2/": proxyconnect tcp: dial tcp: lookup http.docker.internal on 192.168.65.7:53: read udp 192.168.0.1:49962->192.168.65.7:53: i/o timeout

Upvotes: 6

Views: 30731

Answers (1)

tpimh
tpimh

Reputation: 578

The reason for this error is platform incompatibility as you correctly pointed out. Currently, the image that you are trying to use is only available for amd64 platform which is only possible to run on M2 processor through emulation. In order to enable Rosetta2 for emulation, you need to run the following command:

softwareupdate --install-rosetta

However, not having this image built for your platform doesn't mean you absolutely have to rely on emulation. Dockerfile is available for this image (however, its location not indicated anywhere on Docker Hub), and you can build it for your platform.

Finally, if you don't depend on this particular image, the easiest option is to find an alternative image that provides the same software and is built for your platform. For example, webhippie/php-apache and silarhi/php-apache are built for arm64 and would work natively without relying on emulation.

Upvotes: 10

Related Questions