Cannot start service prometheus: oci runtime error: container_linux.go:235: starting container process caused "container init exited prematurely"

Cannot start service prometheus: oci runtime error: container_linux.go:235: starting container process caused "container init exited prematurely"

我在运行这个撰写时哪里出错了?

我只想使用持久卷上传这个容器

Compose:

version: '3.1'

services:
  prometheus:
    image: prom/prometheus
    container_name: meta_prometheus
    volumes:
      - ./config:/etc/prometheus/prometheus.yml 
      - ./data:/prometheus/data
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.path=/prometheus/data'
    ports:
      - 9090:9090

Console:

[root@prometheus docker]# docker-compose up -d
Creating meta_prometheus ... error

ERROR: for meta_prometheus  Cannot start service prometheus: oci runtime error: container_linux.go:235: starting container process caused "container init exited prematurely"


ERROR: for prometheus  Cannot start service prometheus: oci runtime error: container_linux.go:235: starting container process caused "container init exited prematurely"

ERROR: Encountered errors while bringing up the project.

这部分是错误的,因为您正在尝试将目录 (./config) 挂载到文件中... /etc/prometheus/prometheus.yml .. 这没有意义..

volumes:
  - ./config:/etc/prometheus/prometheus.yml 

也许你想写

volumes:
  - ./config/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml