Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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

Ask Question

Where am I going wrong when running this compose?

I would just like to upload this container with compose using persistent volume

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.
                check the permissions of your folder or file config and data (if it is linux ls -lh), suddenly they are with user ROOT.
– lorecardoto
                May 15, 2021 at 0:04

This part is wrong, as you're trying to mount a directory (./config) onto a file ... /etc/prometheus/prometheus.yml .. Which does not make sense..

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

Maybe you wanted to write

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

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.