Correct way to specify memory

Hi

I am running this docker-compose, it is essentially the one in your example, I just changed the image slightly.

version: "2"

services:
  sonarqube:
    image: sonarqube:8.2
    depends_on:
      - db
    ports:
      - "9000:9000"
    networks:
      - sonarnet
    environment:
      SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar
      SONAR_JDBC_USERNAME: sonar
      SONAR_JDBC_PASSWORD: sonar
    volumes:
      - sonarqube_data:/opt/sonarqube/data
      - sonarqube_extensions:/opt/sonarqube/extensions
      - sonarqube_logs:/opt/sonarqube/logs
  db:
    image: postgres
    networks:
      - sonarnet
    environment:
      POSTGRES_USER: sonar
      POSTGRES_PASSWORD: sonar
    volumes:
      - postgresql:/var/lib/postgresql
      # This needs explicit mapping due to https://github.com/docker-library/postgres/blob/4e48e3228a30763913ece952c611e5e9b95c8759/Dockerfile.template#L52
      - postgresql_data:/var/lib/postgresql/data

networks:
  sonarnet:
    driver: bridge

volumes:
  sonarqube_data:
  sonarqube_extensions:
  sonarqube_logs:
  postgresql:
  postgresql_data:

But I am getting this error

| ERROR: [1] bootstrap checks failed
sonarqube_1 | [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

I’ve seen this before, but I’m not sure the recommended way to fix this within the Docker container as the container never starts. I’m assuming it wants this inside the docker container?

As an additional question, do you have any examples of docker-compose with SSL certificates. I’m migrating to docker and would like to run it behind SSL

Thanks

:smile:

Hi Jonny
thanks for this double topic :grinning:

For the first one about kernel configuration, it should not be configured at container level but at host level, and would thus depend on your OS.
As this is triggered by the embedded elasticsearch instance, it is nicely explained with https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html.

About HTTS for your SonarQube, it should be done in a very similar way to https for local system instances, described with Operating the Server documentation page. You need to provide an HTTPS front-end and restrict direct access to SonarQube.
For a docker compose instance, I would use an nginx container mapping 443 port only, and when it works you can isolate your sonarqube container in ‘sonarnet’ by not mapping its 9000 port to your host network.

Let me know if this helps.
Best regards
Sylvain