How to increase the vm.max_map_count in AWS ECS fargate?

Viewed 3249

I am trying to run a sonarqube app on the AWS fargate platform. When I run the raw docker image it works like a charm. But If I pass the JDBC properties to the container as an argument I am facing the following issue. Apparently, the elastic search needs a new config. If it is an ECS cluster I would have ssh into the EC2 instances and update these properties. In the case of fargate, how do I achieve this?

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

2 Answers

From the github issue seems like it not possible as there is no EC2 instance or Host ivolvole in Fargate.

the workarounds for the max_map_count error appear to be setting max_memory_map directly on the host (which may result in undesirable side effects, or using the sysctl flag on on the docker run command. Unfortunately, neither of these options are not supported in Fargate since it involves interacting with the container instance itself.

But the other way is to increase file limit and disable mmap check.

I had to properly configure U limits on my ECS task definition, something like:
"ulimits": [
  {
    "name": "nofile",
    "softLimit": 65535,
    "hardLimit": 65535
  }
]

I've disabled mmap in ElasticSearch, which gets rid of the max_map_count setting requirement. This can be done by configuring the sonar.search.javaAdditionalOpts SonarQube setting. I wasn't able to do it with an environment variable since ECS seems to be eating them, but in the end I just passed it as a parameter to the container, which works since the entrypoint is set and consumes arguments properly. In my case:

"command": [
  "-Dsonar.search.javaAdditionalOpts=-Dnode.store.allow_mmapfs=false"
]

sonarqube disable nmap

Adding the variable discovery.type = single-node under the "Environment Variables" section (edit the es container) in the task definition resolved the issue for me. If you're using the json file, then add the following section

"environment": [
        {
          "name": "discovery.type",
          "value": "single-node"
        }
      ],

Unfortunately, I don't know why that worked.

Related