Run linux/arm container via qemu binfmt_misc on Docker LCOW

  docker, docker-on-windows, linux, windows

I release ARM binaries of my software, by running the compiler toolchain on an emulated ARM machine.

Linux can run foreign binaries by registering qemu-user-static in /proc/sys/fs/binfmt_misc/. This allows you to run an ARM32 or ARM64 Docker image on an x86_64 Docker host, as follows:

Preparation:

# Apply `binfmt_misc` changes on host OS
docker run --rm --privileged multiarch/qemu-user-static:register --reset

Dockerfile:

# Get x86_64 qemu-user-static binaries
FROM debian:buster
RUN apt-get update && apt-get install -qqy qemu-user-static

# Get cross-arch rootfs
FROM arm64v8/golang:latest
COPY --from=0 /usr/bin/qemu-aarch64-static /usr/bin/qemu-aarch64-static

This works great on Docker for Linux.

It also works great on Docker for Windows when using Linux Containers (MobyLinuxVM)

It doesn’t work when using Docker for Windows when using Windows Containers (LCOW / hcsdiag mode). I want to use this mode because it can run both Linux and Windows containers. But it’s not possible to modify the binfmt_misc file via the --privileged flag:

C:Program FilesDockerDockerResourcesbindocker.exe: Error response from daemon: Windows does not support privileged mode.
See 'C:Program FilesDockerDockerResourcesbindocker.exe run --help'.

Current (1803-era) versions of Hyper-V HCS run a real Linux kernel, not a WSL one. I guess it should be possible to modify the host’s binfmt_misc directory.

  • How is it possible to run a Linux/ARM container image on a Windows/x86_64 Docker host running LCOW?

  • Is it possible to modify the Linux host image used by LCOW?

  • Is there any other way to get a unified docker daemon that is capable of running Windows/x86_64, Linux/x86_64 and Linux/ARM Docker images?

Source: StackOverflow

LEAVE A COMMENT