'Set default platform for image pull on ARM arch docker runner

I have a mac mini with an m1 which I am using in conjunction with fastlane to build some mobile apps. I installed the gitlab runner using the official installation instructions, which installs everything on the machine itself and the setup works without any issues.

I now want to also build x86 projects, more specifically Java projects. I installed another runner using docker, and when pulling the image I specified --platform=linux/amd64. The runner started correctly, is using the amd64 arch and I was able to register it without issues.

My problem is in building the projects. Whenever I specify the image for building (in my case maven:3-jdk-12), the build fails with the following message:

Running with gitlab-runner 14.9.1 (bd40e3da)
  on <REDACTED>-docker-runner wvYKr4F1
Preparing the "docker" executor
Using Docker executor with image maven:3-jdk-12 ...
Pulling docker image maven:3-jdk-12 ...
WARNING: Failed to pull image with policy "always": no matching manifest for linux/arm64/v8 in the manifest list entries (manager.go:203:4s)
ERROR: Job failed: failed to pull image "maven:3-jdk-12" with specified policies [always]: no matching manifest for linux/arm64/v8 in the manifest list entries (manager.go:203:4s)

so it looks like that the image being pulled is the one detected by the docker client on the machine (so arm64). Is there any way to specify the platform for this runner, without having to change every `.gitlab-ci.yml? My goal is to have an x86 runner inside of docker and select it with tags



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source