docker-compose build sonarqube

Create mount data directory

mkdir -p /opt/sonarqube/conf
mkdir -p /opt/sonarqube/data
mkdir -p /opt/sonarqube/extensions
mkdir -p /var/lib/postgresql/data

Write docker-compose.yaml

version: "2"
services:
  sonarqube:
    image: sonarqube
    restart: always
    ports:
      - "9900:9000"
    depends_on:
      - db
    networks:
      - sonarnet
    environment:
      - SONAR_JDBC_USERNAME=sonar
      - SONAR_JDBC_PASSWORD=sonar123
      - SONAR_JDBC_URL=jdbc:postgresql://db:5432/sonarqube
      - SONARQUBE_JDBC_USERNAME=sonar
      - SONARQUBE_JDBC_PASSWORD=sonar123
      - SONARQUBE_JDBC_URL=jdbc:postgresql://db:5432/sonarqube
    volumes:
      - /opt/sonarqube/conf:/opt/sonarqube/conf
      - /opt/sonarqube/data:/opt/sonarqube/data
      - /opt/sonarqube/extensions:/opt/sonarqube/extensions

  db:
    image: postgres
    restart: always
    networks:
      - sonarnet
    environment:
      - POSTGRES_USER=sonar
      - POSTGRES_PASSWORD=sonar123
      - POSTGRES_DB=sonarqube
    volumes:
      - /var/lib/postgresql/data:/var/lib/postgresql/data

networks:
  sonarnet:
    driver: bridge

start up

docker-compose up

access

ip address+9900

Guess you like

Origin blog.csdn.net/qq_33235529/article/details/107517950