第一步:拉取镜像
docker pull postgres
docker pull sonarqube:8.9.3-community
第二步:编写docker-compoe.yml
version: "3.1"
services:
db:
image: postgres
container_name: db
ports:
- 5432:5432
networks:
- sonarnet
environment:
POSTGRES_USER: sonar
POSTGRES_PASSWORD: sonar
sonarqube:
image: sonarqube:8.9.3-community
container_name: sonarqube
depends_on:
- db
ports:
- "9000:9000"
privileged: true #以获取root权限
networks:
- sonarnet
environment:
SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar
SONAR_JDBC_USERNAME: sonar
SONAR_JDBC_PASSWORD: sonar
networks:
sonarnet:
driver: bridge
第三步:启动容器
docker-compose up -d
第四步:修改sysctl.conf文件信息
启动报错:原因elasticsearch 的vm.max_map_coun太小调整为262144
docker exec -it -u root 4f857bb34481 /bin/bash
#获取root权限
vi /etc/sysctl.conf
# 末尾添加vm.max_map_count=262144
sysctl -p
第五步:重新启动容器
2023-04-22 22:00:12 2023.04.22 14:00:12 INFO ce[][o.s.p.ProcessEntryPoint] Starting ce
2023-04-22 22:00:12 2023.04.22 14:00:12 INFO ce[][o.s.ce.app.CeServer] Compute Engine starting up...
2023-04-22 22:00:14 2023.04.22 14:00:14 INFO ce[][o.s.s.e.EsClientProvider] Connected to local Elasticsearch: [http://localhost:9001]
2023-04-22 22:00:16 2023.04.22 14:00:16 INFO ce[][o.sonar.db.Database] Create JDBC data source for jdbc:postgresql://db:5432/sonar
2023-04-22 22:00:24 2023.04.22 14:00:24 INFO ce[][o.s.s.p.ServerFileSystemImpl] SonarQube home: /opt/sonarqube
2023-04-22 22:00:24 2023.04.22 14:00:24 INFO ce[][o.s.c.c.CePluginRepository] Load plugins
2023-04-22 22:00:33 2023.04.22 14:00:33 INFO ce[][o.s.c.c.ComputeEngineContainerImpl] Running Community edition
2023-04-22 22:00:33 2023.04.22 14:00:33 INFO ce[][o.s.ce.app.CeServer] Compute Engine is operational
2023-04-22 22:00:33 2023.04.22 14:00:33 INFO app[][o.s.a.SchedulerImpl] Process[ce] is up
2023-04-22 22:00:33 2023.04.22 14:00:33 INFO app[][o.s.a.SchedulerImpl] SonarQube is up
启动: http://localhost:900 admin/admin
DevOps极速入门丨Gitlab丨Jenkins丨harbor丨CICD丨自动化丨运维开发_慧闲大大的博客-CSDN博客
问题解决
一、解决jenkins插件不能下载的问题:升级最新jenkins.jar包去官网下载 放进jenkins_home,重新启动完成jenkins升级。
二、解决docker部署 Sonar Qube问题希望有帮助
https://blog.csdn.net/qq_40342015/article/details/130311409