| .woodpecker | Added same-arch cross containers | |
| docker-entrypoint.sh | Disabled qemu-binfmt on same-arch guests | |
| Dockerfile | Renamed project | |
| LICENSE | Added AGPL license | |
| qemu-user-binfmt.txt | Added file from https://git.sr.ht/~postmarketos/pmbootstrap/blob/master/pmb/data/qemu-user-binfmt.txt | |
| README.org | Added woodpecker CI | |
alpine-cross
This project allows you to build docker files,
that run on one architecture (HOST_ARCH)
but execute commands on a different architecture (GUEST_ARCH).
For example, you could build a Docker image, that runs on your x86_64 host CI, using which you can run/build aarch64 binaries.
Dockerfile Build Options
GUEST_ARCH, the architecture the container is supposed to emulate (can be any of the architectures, that have an alpine chroot available. You can find a list here).ALPINE_VERSION, allows you to specify which alpine version the chroot runs on. (Might be limited depending on whichGUEST_ARCHyou chose)CHROOT_DIR, where the chroot is located inside of the Docker container. This is set to/chrootby default, and you probably won't need to change this.
Building
As of writing the docker image can be build by marking the Dockerfile as executable, and then executing it:
chmod +x Dockerfile
./Dockerfile
# if you do not have docker setup to run rootless,
# you might have to prepend sudo or doas to the previous command
If you do not feel comfortable with marking Dockerfiles as executable, you can use the following command instead:
docker build . -t alpine-cross
# if you do not have docker setup to run rootless,
# you might have to prepend sudo or doas to the previous command
BuildX
If you want to build the container for a different HOST_OS,
you can use docker buildx:
docker buildx build --platform linux/arm64 . -t alpine-cross
# if you do not have docker setup to run rootless,
# you might have to prepend sudo or doas to the previous command
The following platforms are currently supported by the alpine docker image: (This does not mean that they work, but these are the possible values)
- amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, riscv64, s390x
For an up-to-date list, you might want to check the alpine docker hub page
Running the container
To run the container,
you have to add the --privileged option to docker run.
For example to validate your setup, you could run the following command.
docker run --privileged -it alpine-cross uname -m
# if you do not have docker setup to run rootless,
# you might have to prepend sudo or doas to the previous command
This should print the architecture name of the GUEST_ARCH
As you may have noticed from the command above, the chroot accepts command line parameters. By using them, you can also start a shell:
docker run --privileged -it alpine-cross ash
# if you do not have docker setup to run rootless,
# you might have to prepend sudo or doas to the previous command
Persistence
To persist the chroot you have to bind mount the CHROOT_DIR.
Prebuilds
You can find prebuild containers on codeberg.
Resources
For more information on binfmt_misc,
I found the following websites helpful: