When I put the JDBC settings inside the docker-compose file, I get an error

Hi. I’m setting up using docker-compose.

Here is my source

  # postgresDB
  sonar_db:
    image: myip/postgres
    ports:
      - '5432:5432'
    volumes:
      - postgresql:/var/lib/postgresql
      - postgresql_data:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: sonar
      POSTGRES_PASSWORD: sonar
      POSTGRES_DB: sonar
    networks:
      backend:
    restart: always

  # Test Tool Sonarqube
  sonarqube:
    image: sonarqube:community
    depends_on: [sonar_db]
    ports:
      - '9000:9000'
    volumes:
      - sonarqube_data:/opt/sonarqube/data
      - sonarqube_extensions:/opt/sonarqube/extensions
      - sonarqube_logs:/opt/sonarqube/logs
    environment:
      SONAR_JDBC_URL: jdbc:postgresql://sonar_db:5432/sonar
      SONAR_JDBC_USERNAME: sonar
      SONAR_JDBC_PASSWORD: sonar
    networks:
      backend:

The error is as follows

2024.05.13 00:45:06 ERROR es[][o.e.b.Elasticsearch] node validation exception
[1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch. For more information see [https://www.elastic.co/guide/en/elasticsearch/reference/8.11/bootstrap-checks.html]
bootstrap check failure [1] of [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]; for more information see [https://www.elastic.co/guide/en/elasticsearch/reference/8.11/_file_descriptor_check.html]
2024.05.13 00:45:06 WARN  es[][o.e.n.Node] unexpected exception while waiting for http server to close
java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Can't move to stopped state when not started
	at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:?]
	at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:?]
	at org.elasticsearch.node.Node.prepareForClose(Node.java:1776) ~[elasticsearch-8.11.0.jar:?]
	at org.elasticsearch.bootstrap.Elasticsearch.shutdown(Elasticsearch.java:468) ~[elasticsearch-8.11.0.jar:?]
	at java.lang.Thread.run(Unknown Source) ~[?:?]
Caused by: java.lang.IllegalStateException: Can't move to stopped state when not started
	at org.elasticsearch.common.component.Lifecycle.canMoveToStopped(Lifecycle.java:128) ~[elasticsearch-8.11.0.jar:?]
	at org.elasticsearch.common.component.AbstractLifecycleComponent.stop(AbstractLifecycleComponent.java:73) ~[elasticsearch-8.11.0.jar:?]
	at org.elasticsearch.node.Node.lambda$prepareForClose$59(Node.java:1768) ~[elasticsearch-8.11.0.jar:?]
	at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:?]
	... 1 more

If you remove the JDBC settings here, it works fine.

For what reason is this happening?

Any help would be appreciated. Please.,…

Hi

If you remove the JDBC url, then it will use default embedded H2 database, which is not what you want.

Have you checked the logs of the DB ? Maybe it is not starting properly, so SQ cannot connect to it

The DB is working fine.
I also created user and database, and authorized them.
I’ve tried two versions of postgres, 12 and 15, but it doesn’t work…

Error is:

bootstrap check failure [1] of [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]

You must ensure your host is properly configured, and matches Docker Host Requirements (also check on page Docker)

Then add following in your SQ service:

    ulimits:
      nofile:
        soft: 131072
        hard: 131072