防火墙重启之后,需要重启docker

    1. sudo systemctl restart docker

    https://www.cnblogs.com/paopaohll/p/13223433.html
    docker-compose.yml

    1. version: '3'
    2. services:
    3. db:
    4. image: postgres
    5. restart: always
    6. container_name: db
    7. ports:
    8. - 5432:5432
    9. environment:
    10. TZ: Asia/Shanghai
    11. POSTGRES_USER: sonar
    12. POSTGRES_PASSWORD: sonar
    13. POSTGRES_DB: sonar
    14. networks:
    15. - sonarnet
    16. sonarqube:
    17. image: sonarqube:8.9.7-community
    18. restart: always
    19. container_name: sonarqube
    20. depends_on:
    21. - db
    22. ports:
    23. - 9000:9000
    24. command:
    25. # 内存设置
    26. - -Dsonar.ce.javaOpts=-Xmx2048m
    27. - -Dsonar.web.javaOpts=-Xmx2048m
    28. environment:
    29. SONARQUBE_JDBC_USERNAME: sonar
    30. SONARQUBE_JDBC_PASSWORD: sonar
    31. SONARQUBE_JDBC_URL: jdbc:postgresql://db:5432/sonar
    32. networks:
    33. - sonarnet
    34. networks:
    35. sonarnet:
    36. driver: bridge
    1. # 编辑docker-compose.yml文件
    2. version: '3'
    3. services:
    4. postgres:
    5. image: postgres:12.3
    6. restart: always
    7. container_name: postgres
    8. ports:
    9. - 5432:5432
    10. volumes:
    11. - /home/sonar/postgres/postgresql:/var/lib/postgresql
    12. - /home/sonar/postgres/data:/var/lib/postgresql/data
    13. - /etc/localtime:/etc/localtime:ro
    14. environment:
    15. TZ: Asia/Shanghai
    16. POSTGRES_USER: sonar
    17. POSTGRES_PASSWORD: sonar
    18. POSTGRES_DB: sonar
    19. sonar:
    20. image: sonarqube:7.9.2-community
    21. container_name: sonar
    22. depends_on:
    23. - postgres
    24. volumes:
    25. - /home/sonar/sonarqube/extensions:/opt/sonarqube/extensions
    26. - /home/sonar/sonarqube/logs:/opt/sonarqube/logs
    27. - /home/sonar/sonarqube/data:/opt/sonarqube/data
    28. - /home/sonar/sonarqube/conf:/opt/sonarqube/conf
    29. # 设置与宿主机时间同步
    30. - /etc/localtime:/etc/localtime:ro
    31. ports:
    32. - 59000:9000
    33. command:
    34. # 内存设置
    35. - -Dsonar.ce.javaOpts=-Xmx2048m
    36. - -Dsonar.web.javaOpts=-Xmx2048m
    37. # 设置服务代理路径
    38. - -Dsonar.web.context=/
    39. # 此设置用于集成gitlab时,回调地址设置
    40. - -Dsonar.core.serverBaseURL=https://sonarqube.example.com
    41. environment:
    42. TZ: Asia/Shanghai
    43. SONARQUBE_JDBC_USERNAME: sonar
    44. SONARQUBE_JDBC_PASSWORD: sonar
    45. SONARQUBE_JDBC_URL: jdbc:postgresql://postgres:5432/sonar