1:起consul单点 1.9.7版本
##docker run consul-1.9.7
docker run -itd --name devops-consul-1.9.7 -p 8500:8500 -v /opt/consul/config/:/consul/config/ -v /opt/consul/kv.json:/kv.json -v /opt/consul/custom_conf.json:/custom_conf.json -v /opt/consul/data:/var/consul --restart=always a575ae275523 agent -server
2:起mariadb数据库
docker run -itd --name devops-mariadb -p 3379:3306 -e MYSQL_ROOT_PASSWORD=cent@123 -v /var/lib/mysql:/var/lib/mysql -v /etc/localtime:/etc/localtime -v /opt/mysql/my.cnf:/etc/mysql/my.cnf --restart=always fc48e0ee0995
3:起jenkins2.263
docker run -itd --name devops-jenkins-master -p 8778:8080 -p 50000:50000 -v /opt/jenkins/jenkins_home:/var/jenkins_home -e JAVA_TOOL_OPTIONS='-Dfile.encoding=UTF-8' -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker --restart=always 0e99ac5d110c
4:起sonar
sysctl -w vm.max_map_count=262144 #调整内核参数,不然sonar中依赖的elasticsearch启动不了,报内存锁错误
#再启动postgre,sonar依赖postgre数据库
docker run -d --name devops-sonar-postgres \
-e POSTGRES_USER=sonar \
-e POSTGRES_PASSWORD=123456 \
-p 5432:5432 \
-v /opt/postgresql/data:/var/lib/postgresql/data \
--restart=always postgres:12.4-alpine
##启动sonar容器
docker run -d --name devops-sonar \
--link devops-sonar-postgres \
-p 9000:9000 \
-e SONAR_JDBC_URL=jdbc:postgresql://10.10.10.2:5432/sonar \
-e SONAR_JDBC_USERNAME=sonar \
-e SONAR_JDBC_PASSWORD=123456 \
-v /opt/sonarqube/extensions:/opt/sonarqube/extensions \
-v /opt/sonarqube/logs:/opt/sonarqube/logs \
-v /opt/sonarqube/data:/opt/sonarqube/data \
--restart=always sonarqube:8.4.2-community
#报数据库的错误就去postgre数据库中查看sonar存不存在
psql -h127.0.0.1 -p 5432 -U sonar sonar #能进入就没问题