无法启动服务 prometheus:oci 运行时错误:container_linux.go:235:启动容器进程导致“容器初始化过早退出”

Posted

技术标签:

【中文标题】无法启动服务 prometheus:oci 运行时错误:container_linux.go:235:启动容器进程导致“容器初始化过早退出”【英文标题】:Cannot start service prometheus: oci runtime error: container_linux.go:235: starting container process caused "container init exited prematurely" 【发布时间】:2021-02-10 02:22:18 【问题描述】:

运行此撰写时我哪里出错了?

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

撰写:

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

控制台:

[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.

【问题讨论】:

检查你的文件夹或文件配置和数据的权限(如果是linux ls -lh),突然他们与用户ROOT。 【参考方案1】:

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

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

也许你想写

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

【讨论】:

/etc/prometheus:/etc/prometheus/,这也解决了,感谢您的帮助!

以上是关于无法启动服务 prometheus:oci 运行时错误:container_linux.go:235:启动容器进程导致“容器初始化过早退出”的主要内容,如果未能解决你的问题,请参考以下文章