一、Docker 版本
二、查看可安装的版本
docker search prom/prometheus
三、拉取镜像
docker pull prom/prometheus
四、查看本地镜像
docker images
五、创建挂载目录或文件
宿主机位置 | 容器位置 |
/usr/local/promethues/server/prometheus.yml | /etc/prometheus/prometheus.yml |
global:
scrape_interval: 60s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 60s # Evaluate rules every 15 seconds. The default is every 1 minute.
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ['172.17.0.1:8892']
labels:
instance: prometheus
六、运行 Prometheus
# -d:后台运行
# -p:将容器内部端口向外映射
# --name:命名容器名称
# -v:将容器内数据文件夹或者日志、配置等文件夹挂载到宿主机指定目录
docker run -itd --name prometheus -p 8892:9090 \
-v /usr/local/promethues/server/prometheus.yml:/etc/prometheus/prometheus.yml \
-v /etc/localtime:/etc/localtime:ro \
prom/prometheus
七、访问:http://ip:8892/
注:以上内容仅提供参考和交流,请勿用于商业用途,如有侵权联系本人删除!