docker-compose启动prometheus
核心配置
version: '3' # 指定docker-compose版本 services: nginx: image: nginx # 指定镜像 container_name: nginx # 容器名称 restart: unless-stopped # 启动方式 ports: # 端口映射 - 80:80 environment: # 环境变量 - key1=value1 - key2=value2 - key3=value3 depends_on: # 依赖的容器,依赖的容器启动之后该容器才启动 - another_container networks: # 网络 - networkName command: # 命令 - com1 - com2 - com3 volumes: # 卷 - hostPath1:containerPath1:ro - hostPath2:containerPath2:ro
实例:
version: '3' networks: monitor: driver: bridge services: prometheus: privileged: true image: prom/prometheus container_name: prometheus hostname: prometheus restart: always volumes: - /root/prom/workSpace/common_services/prometehus/prometheus.yml:/etc/prometheus/prometheus.yml - /root/prom/workSpace/common_services/prometehus/alertmanager.yml:/etc/prometheus/alertmanager.yml - /root/prom/workSpace/common_services/prometehus/rules/:/etc/prometheus/rules/ ports: - "9090:9090" networks: - monitor # entrypoint: (这个命令在这里有问题,不要用) command: - /bin/prometheus - --config.file=/etc/prometheus/prometheus.yml - --web.enable-lifecycle

浙公网安备 33010602011771号