An example of how to run a SonarQube webapp instance using Docker on an M1 Mac
MIT License
SonarQube has confirmed that they're working on an arm64 compatible image, and provided a local build solution:
git clone [email protected]:SonarSource/docker-sonarqube.git
cd docker-sonarqube/9/community
git checkout 9.7.0 # you can specify which sonarqube version to build
docker build -t sonarqube:9.7.0-community .
Pull down the docker build and run it:
docker pull davealdon/sonarqube-with-docker-and-m1-macs
Specify a port number so that you can go to the Sonar URL: http://localhost:9000/
Clone the repo on your M1 Mac, and run the following command:
docker build -f arm64.Dockerfile -t sonarqubem1 .
docker run -p9000:9000 sonarqubem1
Then go to the URL: http://localhost:9000/
I'm happy to update the project version for you, however if you need a new version quickly, find the full build number you want from the SonarQube distribution binary directory, and plug it into this arg in the arm64.Dockerfile
file:
ARG SONARQUBE_VERSION=X.X.X.X
You can find their nice, 2 minute guide here. But, on an M1 you can only run it locally using the source zip file. I really wanted to use Docker, which is their preferred method anyway.
It didn't work out of the box because you immediately get this error when building:
no matching manifest for linux/arm64/v8 in the manifest list entries
So, they don't have the right manifest for this architecture. You can force it to run in x86_64 mode:
docker run --platform linux/x86_64 sonarqube
But surprise, surprise, of course that doesn't work. You'll get a big error dump talking about Elasticsearch failing and other stuff:
unable to install syscall filter
java.lang.UnsupportedOperationException: seccomp unavailable: CONFIG_SECCOMP not compiled into kernel, CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER are needed
etc. etc.
After further investigation, it turns out that this is something SonarQube isn't really working on, but there's definitely requests for it.
After SonarQube gave the simple response that "we don't support M1" another developer created a solution. This was great, but after trying to pull down mwizner's Docker, I got this error:
Error response from daemon: manifest for mwizner/sonarqube:latest not found: manifest unknown: manifest unknown
Also, mwizner's solution was for v8 of SonarQube, from almost a year ago, and I'm greedy and wanted the latest v9 to work (which matches the SonarQube version my team is using).
A big thanks to my colleague Chris Watts for helping me with this, because I'm a beginner at Docker and was going down the wrong path of trying to containerize SonarQube's source web app manually. I knew the source code worked without Docker for sure, but I didn't understand how to get Docker to work with specific architectures.
This file was the starting point, provided by mwizner's original solution. Chris provided changes to this in some key places:
FROM arm64v8/alpine:3.14.3
and
ZLIB_URL="https://mirrors.dotsrc.org/archlinuxarm/arm/core/zlib-1%3A1.2.11-5-arm.pkg.tar.xz";
ARG SONARQUBE_VERSION=9.3.0.51899
Docker stop
, you're telling Docker to send a signal to the container to stop. By default, this command is SIGTERM
, but some apps may be configured to listen to something else like SIGUSR1
. Therefore, this command was added to manually make sure that SIGINT
is sent to the container upon stopping. This is more of a QoL update, and is explained more here.STOPSIGNAL SIGINT
ENTRYPOINT ["/opt/sonarqube/bin/run.sh"]
CMD ["/opt/sonarqube/bin/sonar.sh"]
docker run -p9000:9000 sonarqubem1
Once again, thank you to Chris Watts for helping me with this! If you want to talk with us about Docker, check out Bravo LT's Discord server here!