Cross-platform docker build

I’m using GitHub - multiarch/qemu-user-static: `/usr/bin/qemu-*-static` to run multi-arch docker containers on my runner host. That works great. However, upon attempting to do the same with the plugins/docker container, in order to build an image for a different architecture, I get an error related to docker being unable to start within the container. The full log of that build step, including the error, is as follows:

+ /usr/local/bin/dockerd --data-root /var/lib/docker --host=unix:///var/run/docker.sock
Detected registry credentials
+ /usr/local/bin/docker version
time="2021-01-16T20:35:10Z" level=error msg="failure getting variant" error="getCPUInfo for pattern: Cpu architecture: not found"
Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b
 Built:             Wed Mar 11 01:23:06 2020
 OS/Arch:           linux/arm64
 Experimental:      false
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
time="2021-01-16T20:35:11Z" level=fatal msg="exit status 1"

I am running the linux-arm64 version (tag) of the docker plugin using the aforementioned qemu, and have installed both qemu-user and qemu-user-static on the host. Running the amd64 version of the plugin works fine. My config for this step is as follows:

- name: build and push docker images
  image: plugins/docker:linux-arm64
  # Neither of the below work - the former makes no difference, and the latter builds x86_64 images as expected, but not desired
  #privileged: true
  #- name: dockersock
  #  path: /var/run/docker.sock
      from_secret: DOCKER_USER
      from_secret: DOCKER_TOKEN
    repo: <username>/<project-name>
    tags: latest
    dockerfile: Dockerfiledendrite-monolith-testing
    context: ./bin/bin/linux_arm64/

It may be worth noting that from within the container (or other similarly configured ones), cat /proc/cpuinfo produces:

processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 79
model name	: Intel(R) Xeon(R) CPU E5-1630 v4 @ 3.70GHz
stepping	: 1
microcode	: 0x1
cpu MHz		: 3699.996
cache size	: 10240 KB
physical id	: 0
siblings	: 1
core id		: 0
cpu cores	: 1
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx smap xsaveopt arat md_clear
bugs		: cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit
bogomips	: 7399.99
clflush size	: 64
cache_alignment	: 64
address sizes	: 46 bits physical, 48 bits virtual
power management:

which seems to be the same as on the host.

This docker issue may also be relevant, although it is about running in a chroot: docker fails to start in chroot qemu environment (error: getCPUInfo) · Issue #1146 · docker/for-linux · GitHub

Is there any way around this? Alternatively, could a cross-build feature be added to the plugins/docker container, possibly using buildx?

Hello u9123,

The particular plugin in question does not support cross-platform docker builds, however, the you can always create your own custom plugin for this purpose.

I see. I didn’t think this needed support from the plugin though, since the whole container is the ARM version and being run by QEMU, so it should theoretically run as though it were on a native ARM host, but I imagine the issue is simply that the container is using some features which are not emulated properly or at all? In that case, if possible, could you shed some light on the possible origin of this error so I can look into it?

@u9123 we do not have any experience with cross-platform docker builds use qemu, so we are not really in a position to offer support on this topic. The source code for this plugin is available, however, in case you are interested in researching the code to triage the error. See

Alright. That’s fair. Thanks