Max File Descriptors error docker container on windows host (Windows Server 2019)

I am trying to run sonarqube in a docker container. Container fails on startup with error “[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]”. The docker host is Windows server 2019 Version 1809 with Docker Engine version 19.03.12 (experimental mode enabled) and does not use Docker for Windows.

To fix the error i have tried:

  1. setting higher ulimits using sysctl on the container but get error sysctl: setting key “fs.file-max”: Read-only file system. Using --privileged flag does not help. Get error C:\Program Files\Docker\docker.exe: Error response from daemon: Windows does not support privileged mode.
  2. setting ulimits by adding default-ulimits to the docker run command but get error C:\Program Files\Docker\docker.exe: Error response from daemon: invalid option: Windows does not support Ulimits.

As far as I can tell this setting should be configured at host level, but that’s not possible for Windows Server 2019. Elasticsearch itself gives alternatives for Docker-Desktop and Docker-Machine / WSL but that’s not what I use (see https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-configuration-methods) Does anyone know any workaround for this issue?

Thanks a lot for any help!

Hello @RHaest and welcome to the community :wave:

this is a rather uncommon combination. have you had a look at this blog post? you might be able to set the limit using net config server but i am no expert on windows :sweat_smile:
tbh i would shoot for a native installation if you have to stick to windows or use a real linux server for your sonarqube installation.

this said: there is a environment variable where you can disable the elasticsearch startup checks: SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true .
again not recommended but this would allow you to start sonarqube in this specific environment.

hope that helps

Hi Tobias, thanks for your answer. I tried the disable variable already, but that doesn’t seem to have any effect:

2020.10.16 11:45:14 INFO  es[][o.e.b.BootstrapChecks] explicitly enforcing bootstrap checks
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]

Btw when I start the container without a linked database (so with the H2 evaluation database), then it starts without a problem (it gives the same messages in the log but as WARN instead of ERROR).

My docker run command:
docker run --name sonarqube -v sonarqube_extensions:/opt/sonarqube/extensions -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -e SONARQUBE_JDBC_USERNAME=*** -e SONARQUBE_JDBC_PASSWORD=*** -e SONAR_JDBC_URL=$url -d sonarqube

Any ideas about that?

I will look into your blog as well, thanks!

Hi @RHaest ,

looks like you found a bug in the env parsing. it will be tracked in SONAR-13997.

you can pass the parameter anyway as an argument to work around this, so:

docker run --name sonarqube -v sonarqube_extensions:/opt/sonarqube/extensions -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -e SONARQUBE_JDBC_USERNAME=*** -e SONARQUBE_JDBC_PASSWORD=*** -e SONAR_JDBC_URL=$url -d sonarqube:8.5-community -Dsonar.es.bootstrap.checks.disable=true

Hi Tobias,

Thanks, tried that but then I get this error:

docker : Exception in thread “main” java.lang.IllegalArgumentException: Command-line argument must start with -D, for example -Dsonar.jdbc.username=sonar. Got: -Dsonar.

It should be at the end of the docker run command?

yeah it should be at the end of the docker run command and it works for me. are you sure that there is nothing in between? if this does not help i really think you should consider a native installation as this environment is really rare and hard to reproduce :confused:

Hi Tobias, I copied your exact command and still got that error, so seems that’s not working either. I will consider a native installation but the goal would be to run it in docker, why is this configuration so rare? It’s quite common to run docker engine on a windows server right?

Thanks anyway for your help this far!

Edit: got rid of the java error by specifying the command in capitals in the end, like -DSONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true but then it still performs the bootstrap checks and gives the error.

on windows you would either run docker for windows with wsl2 or docker machine. docker machine would allow you do ssh into the virtual machine ( docker-machine ssh default ) and change the settings there while docker for windows would allow you to make use of native features as documented in the elastic docs. plain docker engine lacks these possibilities as it is tightly mangled to hyper-v to my knowledge :man_shrugging:

this can not work as you can not pass an environment variable as a jvm argument property

Hi Tobias,

Thanks, I’ll just wait till the environment variable thing works, both passing as -e (environment variable) as passing it as property at the end in the docker run command does not work back to sonarqube version 7.9 (tried all those versions). In the meantime I will look to a native installation possibility.

Edit: got it to work with the property part, had to pass it as a var, so if everyone needs this ever this was the solution for me:

$key = ‘-Dsonar.es.bootstrap.checks.disable=true’
docker run --name sonarqube -e SONARQUBE_JDBC_USERNAME=** -e SONARQUBE_JDBC_PASSWORD=**-e SONAR_JDBC_URL=$url sonarqube $key

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.