docker - Prometheus不是在vm上运行,而是在本地Docker上运行

标签 docker virtual-machine prometheus

我正在尝试让普罗米修斯在vm上运行。我有几个要监视的微服务,它们正在vm上运行。我将以下内容添加到docker-compose.yml文件之一:

prometheus:
    image: prom/prometheus:v2.1.0
    volumes:
        - ./prometheus.yml:/etc/prometheus/prometheus.yml
    command:
        - '--config.file=/etc/prometheus/prometheus.yml'
    ports:
        - '9090:9090'

然后将prometheus.yml文件添加到与上述docker-compose相同的文件夹中。
global:
  scrape_interval:     15s 
  evaluation_interval: 15s 



scrape_configs:

  - job_name: 'prometheus'

    static_configs:
        - targets: ['localhost:9090']

 - job_name: 'radios-service'


   metrics_path: '/prometheus-metrics'
   static_configs:
        - targets: ['radios-service:8080']

 - job_name: 'websocket-service'
   metrics_path: '/prometheus-websocket'
   static_configs:
      - targets: ['websocket-service:8080']

这可以通过我的命令行在docker上成功运行,但是当我尝试在vm上运行它时会抛出此错误:

ERROR: for prometheus Cannot start service prometheus: b'OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\"/usr/local/bin/prometheus.yml\\" to rootfs \\"/var/lib/docker/overlay2/f4b34c5866b191683d4e8c08e59fb14f56127cbcd67a603225954dd59c0a6a50/merged\\" at \\"/var/lib/docker/overlay2/f4b34c5866b191683d4e8c08e59fb14f56127cbcd67a603225954dd59c0a6a50/merged/etc/prometheus/prometheus.yml\\" caused \\"not a directory\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type' ERROR: Encountered errors while bringing up the project.



但是当我在本地运行它不会引发任何问题。虚拟机中的问题可能是什么?

最佳答案

我通过在docker compose中编辑卷行来解决它。我猜在Linux机器上,您需要提供绝对路径。我将prometheus.yml放在/ home /目录中,并将路径更改为如下所示:

prometheus:
image: prom/prometheus:v2.1.0
volumes:
    - /home/prometheus.yml:/etc/prometheus/prometheus.yml
command:
    - '--config.file=/etc/prometheus/prometheus.yml'
ports:
    - '9090:9090'

这似乎有效。

关于docker - Prometheus不是在vm上运行,而是在本地Docker上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51267889/

相关文章:

docker - 如何将docker-compose应用部署到heroku?

elasticsearch - 如何在运行官方 Elasticsearch docker 镜像时设置默认 'elastic' 用户密码?

python - 使用 Vagrant 托管 PostgreSQL 数据库时如何找到我的同步文件夹?

azure - 我如何诊断Azure VM下降的原因 "This virtual machine is stopping and deallocating as requested by an authorized user or process."

kubernetes - 普罗米修斯只刮掉一个 pod

kubernetes - 如何在k8s clus中更新Prometheus配置

prometheus - 如何处理 "prometheus"和 "prometheus_replica"标签?

node.js - 如何解决 yarn 生成错误-错误:ENOTEMPTY:目录不为空,rmdir '/frontend/out/node_modules/cacache/node_modules/.bin'

docker - org.apache.druid.java.util.common.ISE : No default server found

JavaFX 模块对 VM 不可见