https://rancher.com/ logo
Title
a

average-iron-93428

06/23/2022, 2:56 PM
What's the right way to build amd64 images on rancher desktop on an M1 mac? Docker socket doesn't appear to be running.
nerdctl
works except it doesn't work with
--platform amd64
and I get binary exec format errors.
docker buildx inspect --bootstrap           
Name:   qemu
Driver: docker-container

Nodes:
Name:      qemu0
Endpoint:  unix:///var/run/docker.sock
Status:    running
Platforms: linux/arm64, linux/amd64, linux/amd64/v2
docker buildx build . --platform linux/amd64
...
cannot execute binary file: Exec format error
I've run these on a normal x86 machine and they worked fine. It's specific to the M1. It seems like the socket isn't running with rosetta or whatever is needed.
p

powerful-translator-97088

06/23/2022, 4:25 PM
i don't use buildx but
docker build --platform linux/amd64 -t name .
works for me
a

average-iron-93428

06/23/2022, 4:46 PM
docker build --platform linux/amd64 .
throws the same error
cannot execute binary file: Exec format error
f

fast-garage-66093

06/23/2022, 8:10 PM
@average-iron-93428 Do you also have Docker Desktop installed on your machine? The output above doesn't look like it comes from Rancher Desktop, which should produce something like this:
% docker buildx inspect --bootstrap
Name:   default
Driver: docker

Nodes:
Name:      default
Endpoint:  default
Status:    running
Platforms: linux/arm64, linux/amd64
Maybe check
% docker info | grep Name:
 Name: lima-rancher-desktop
Running both Docker and Rancher Desktop simultaneously is not really supported, but should work if you don't give Rancher Desktop admin permissions. In that case you can switch to the Rancher Desktop socket with
% docker context use rancher-desktop
I do however still get problems from
buildx
on the M1 machine, but I'm still investigating those. But running
docker build --platform linux/amd64 .
works just fine.
a

average-iron-93428

06/23/2022, 8:47 PM
@fast-garage-66093 I do have both installed but I'm using Rancher Desktop.
docker info | grep Name:
 Name: lima-rancher-desktop
f

fast-garage-66093

06/23/2022, 8:49 PM
Then I don't understand the output of your
docker buildx inspect
command above.
p

powerful-translator-97088

06/23/2022, 8:50 PM
make sure too that you are using the client it comes with:
❯ which docker
/Users/xxxxx/.rd/bin/docker
f

fast-garage-66093

06/23/2022, 8:50 PM
Can you check
ls -l ~/.docker/cli-plugins
as well?
I had some old/broken symlinks in there that Rancher Desktop didn't update.
I suspect you may have the DD versions installed there
% docker buildx version
<http://github.com/docker/buildx|github.com/docker/buildx> v0.8.2 6224def4dd2c3d347eee19db595348c50d7cb491
a

average-iron-93428

06/23/2022, 8:51 PM
which docker
/opt/homebrew/bin/docker
oh...look at that...
f

fast-garage-66093

06/23/2022, 8:53 PM
I don't think this matters as long as it is a fairly recent version
% docker version
Client:
 Version:           20.10.16
 API version:       1.41
 Go version:        go1.17.10
 Git commit:        aa7e414
 Built:             Wed Jun  1 21:26:39 2022
 OS/Arch:           darwin/arm64
 Context:           rancher-desktop
 Experimental:      true

Server:
 Engine:
  Version:          20.10.16
  API version:      1.41 (minimum version 1.12)
a

average-iron-93428

06/23/2022, 9:05 PM
docker version
Client:
 Cloud integration: v1.0.25
 Version:           20.10.16
 API version:       1.41
 Go version:        go1.17.10
 Git commit:        aa7e414
 Built:             Thu May 12 09:20:34 2022
 OS/Arch:           darwin/arm64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.16
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.10
  Git commit:       f756502055d2e36a84f2068e6620bea5ecf09058
  Built:            Sun May 15 14:59:12 2022
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          v1.5.11
  GitCommit:        3df54a852345ae127d1fa3092b95168e4a88e2f8
 runc:
  Version:          1.1.2
  GitCommit:        
 docker-init:
  Version:          0.19.0
  GitCommit:
f

fast-garage-66093

06/23/2022, 9:33 PM
That all looks good
It works for me now, after running `docker buildx create --use`:
% docker buildx build --platform=linux/arm64,linux/amd64 .
WARNING: No output specified for docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
[+] Building 0.8s (8/8) FINISHED
 => [internal] load build definition from Dockerfile                                                                                          0.0s
 => => transferring dockerfile: 75B                                                                                                           0.0s
 => [internal] load .dockerignore                                                                                                             0.0s
 => => transferring context: 2B                                                                                                               0.0s
 => [linux/amd64 internal] load metadata for <http://docker.io/library/alpine:latest|docker.io/library/alpine:latest>                                                                  0.6s
 => [linux/arm64 internal] load metadata for <http://docker.io/library/alpine:latest|docker.io/library/alpine:latest>                                                                  0.4s
 => [linux/arm64 1/2] FROM <http://docker.io/library/alpine@sha256:686d8c9dfa6f3ccfc8230bc3178d23f84eeaf7e457f36f271ab1acc53015037c|docker.io/library/alpine@sha256:686d8c9dfa6f3ccfc8230bc3178d23f84eeaf7e457f36f271ab1acc53015037c>                   0.0s
 => => resolve <http://docker.io/library/alpine@sha256:686d8c9dfa6f3ccfc8230bc3178d23f84eeaf7e457f36f271ab1acc53015037c|docker.io/library/alpine@sha256:686d8c9dfa6f3ccfc8230bc3178d23f84eeaf7e457f36f271ab1acc53015037c>                               0.0s
 => [linux/amd64 1/2] FROM <http://docker.io/library/alpine@sha256:686d8c9dfa6f3ccfc8230bc3178d23f84eeaf7e457f36f271ab1acc53015037c|docker.io/library/alpine@sha256:686d8c9dfa6f3ccfc8230bc3178d23f84eeaf7e457f36f271ab1acc53015037c>                   0.2s
 => => resolve <http://docker.io/library/alpine@sha256:686d8c9dfa6f3ccfc8230bc3178d23f84eeaf7e457f36f271ab1acc53015037c|docker.io/library/alpine@sha256:686d8c9dfa6f3ccfc8230bc3178d23f84eeaf7e457f36f271ab1acc53015037c>                               0.0s
 => => sha256:2408cc74d12b6cd092bb8b516ba7d5e290f485d3eb9672efc00f0583730179e8 2.80MB / 2.80MB                                                0.1s
 => => extracting sha256:2408cc74d12b6cd092bb8b516ba7d5e290f485d3eb9672efc00f0583730179e8                                                     0.0s
 => CACHED [linux/arm64 2/2] RUN echo "Hello" > /hello                                                                                        0.0s
 => [linux/amd64 2/2] RUN echo "Hello" > /hello                                                                                               0.1s
The fact that even
docker build --platform linux/amd64 .
doesn't work for you means that something is corrupted inside the VM. Can you do a Factory Reset (on the Troubleshooting page), and see if that fixes the issue?