防火墙重启之后,需要重启docker
sudo systemctl restart docker
https://www.cnblogs.com/paopaohll/p/13223433.html
docker-compose.yml
version: '3'
services:
db:
image: postgres
restart: always
container_name: db
ports:
- 5432:5432
environment:
TZ: Asia/Shanghai
POSTGRES_USER: sonar
POSTGRES_PASSWORD: sonar
POSTGRES_DB: sonar
networks:
- sonarnet
sonarqube:
image: sonarqube:8.9.7-community
restart: always
container_name: sonarqube
depends_on:
- db
ports:
- 9000:9000
command:
# 内存设置
- -Dsonar.ce.javaOpts=-Xmx2048m
- -Dsonar.web.javaOpts=-Xmx2048m
environment:
SONARQUBE_JDBC_USERNAME: sonar
SONARQUBE_JDBC_PASSWORD: sonar
SONARQUBE_JDBC_URL: jdbc:postgresql://db:5432/sonar
networks:
- sonarnet
networks:
sonarnet:
driver: bridge
# 编辑docker-compose.yml文件
version: '3'
services:
postgres:
image: postgres:12.3
restart: always
container_name: postgres
ports:
- 5432:5432
volumes:
- /home/sonar/postgres/postgresql:/var/lib/postgresql
- /home/sonar/postgres/data:/var/lib/postgresql/data
- /etc/localtime:/etc/localtime:ro
environment:
TZ: Asia/Shanghai
POSTGRES_USER: sonar
POSTGRES_PASSWORD: sonar
POSTGRES_DB: sonar
sonar:
image: sonarqube:7.9.2-community
container_name: sonar
depends_on:
- postgres
volumes:
- /home/sonar/sonarqube/extensions:/opt/sonarqube/extensions
- /home/sonar/sonarqube/logs:/opt/sonarqube/logs
- /home/sonar/sonarqube/data:/opt/sonarqube/data
- /home/sonar/sonarqube/conf:/opt/sonarqube/conf
# 设置与宿主机时间同步
- /etc/localtime:/etc/localtime:ro
ports:
- 59000:9000
command:
# 内存设置
- -Dsonar.ce.javaOpts=-Xmx2048m
- -Dsonar.web.javaOpts=-Xmx2048m
# 设置服务代理路径
- -Dsonar.web.context=/
# 此设置用于集成gitlab时,回调地址设置
- -Dsonar.core.serverBaseURL=https://sonarqube.example.com
environment:
TZ: Asia/Shanghai
SONARQUBE_JDBC_USERNAME: sonar
SONARQUBE_JDBC_PASSWORD: sonar
SONARQUBE_JDBC_URL: jdbc:postgresql://postgres:5432/sonar