Instalar Sonarqube docker-compose

app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/elasticsearch/bin/elasticsearch

Unos de los principales problemas a la hora de instalar sonarqube en tu maquina local con docker nos sale el siguiente error, o por problema de memoria

app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/elasticsearch/bin/elasticsearch

se puede arreglar con docker compose  

Creamos los directorios

 
mkdir -p ./sonarqube/data
mkdir -p ./sonarqube/extensions
mkdir -p ./sonarqube/logs
mkdir -p ./postgresql/conf
mkdir -p ./postgresql/data
Directorios a crear

Creamos dos archivos

 
├── docker-compose.yml
├── init.sh

modificamos el archivo docker-compose.yml


version: "3.7"
services:
  sonarqube:
    image: sonarqube:8.9.7-community
    depends_on:
      - db
    environment:
      SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar
      SONAR_JDBC_USERNAME: sonar
      SONAR_JDBC_PASSWORD: sonar
    
    volumes:
      
      - type: bind
        source: ./sonarqube/data
        target: /opt/sonarqube/data
      - type: bind
        source: ./sonarqube/extensions
        target: /opt/sonarqube/extensions
      - type: bind
        source: ./sonarqube/logs
        target: /opt/sonarqube/logs
    ports:
      - "9000:9000"
  init:
      image: bash
      privileged: true
      user: root
      volumes:
        - ./init.sh:/mnt/init.sh 
      command: ["sh", "-e", "/mnt/init.sh"]
  db:
    image: postgres:12
    environment:
      POSTGRES_USER: sonar
      POSTGRES_PASSWORD: sonar
    volumes:
      - type: bind
        source: ./postgresql/conf
        target: /var/lib/postgresql
      - type: bind
        source: ./postgresql/data
        target: /var/lib/postgresql/data

docker-compose.yml

modificamos el archivo init.sh


sysctl -w vm.max_map_count=524288
sysctl -w fs.file-max=131072
init.sh

Ejecutamos en la terminal


docker-compose up -d

Verificamos que estén corriendo los dos contenedores


docker container ls
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS              PORTS                    NAMES
5deca7c22ea4        sonarqube:8.9.7-community   "bin/run.sh bin/sona…"   20 hours ago        Up 39 seconds       0.0.0.0:9000->9000/tcp   sonar_sonarqube_1
ca515bffb4bb        postgres:12                 "docker-entrypoint.s…"   20 hours ago        Up 40 seconds       5432/tcp                 sonar_db_1

Referencia:

https://hub.docker.com/_/sonarqube

how can docker-compose run comands as no-root user
how can docker-compose run comands as no-root user? My docker-compose.yml just show below:version: "3"services: sonarqube-h: image: sonarqube:community user: "${UID}:${G...