There is an instruction to run SonarQube with docker on the following URL (see the "Installing the Server from the Docker Image" section):
https://docs.sonarqube.org/latest/setup/install-server/
However, when I started a container with the following command, an Permission Denied error occurred.
$ docker run --name sqx -p 9000:9000 -v /tmp/workdir/data:/opt/sonarqube/data -v /tmp/workdir/extensions:/opt/sonarqube/extensions -v /tmp/workdir/logs:/opt/sonarqube/logs sonarqube:8.2-community
The SonarQube process runs as a user sonarqube (UID=999) within the container. However, if I create volumes (data, extensions, logs) with an owner of myself (UID != 999), the volume will be mounted with an owner of root within the container. Because the sonarqube user does not have a permission to write files to the root-owned directories, the process can't write files and, therefore, the Permission Denied error occurs.
If you mount volumes with an owner of UID=999 on the host, the volumes will be mounted as a sonarqube user owned directories within the container. Followings are the procedure to do so.
Ubuntu is running on host.
$ sudo groupadd -g 999 dockervolume
$ sudo useradd -d /tmp -g dockervolume -s /usr/sbin/nologin -u 999 dockervolume
$ mkdir /tmp/workdir
$ mkdir /tmp/workdir/data
$ mkdir /tmp/workdir/extensions
$ mkdir /tmp/workdir/logs
$ sudo chown -R dockervolume:dockervolume /tmp/workdir
$ docker run --name sqx -p 9000:9000 -v /tmp/workdir/data:/opt/sonarqube/data -v /tmp/workdir/extensions:/opt/sonarqube/extensions -v /tmp/workdir/logs:/opt/sonarqube/logs sonarqube:8.2-community