1

Use case. Why is this important?

centos7 + docker-ce + prometheus

when i run docker-compose the container promises down

see log docker Bug Report

########################### prometheus_1 | ts=2022-12-15T10:14:55.536Z caller=query_logger.go:91 level=error component=activeQueryTracker msg="Error opening query log file" file=/prometheus/queries.active err="open /prometheus/queries.active: permission denied" prometheus_1 | panic: Unable to create mmap-ed active query log ############################

I think it's a volume rights problem, I changed rights and the problem still persists

2 Answers2

2

I had this issue with prometheus:v2.37.7 when trying to mount prometheus data directory from host to container(instead of using pre-defined volumes).

Instead of adding user: root to docker compose you can add an init container to fix directory permissions on /prometheus directory like this:

init_prometheus:
image: prom/prometheus:v2.37.7
user: root
entrypoint:
  - /bin/sh
  - -c
  - |
    chown -R 65534:65534 /prometheus
volumes:
  - /data/prometheus:/prometheus

prometheus:
image: prom/prometheus:v2.37.7
restart: unless-stopped
volumes:
  - /data/prometheus:/prometheus
command:
  - '--config.file=/etc/prometheus/prometheus.yml'
  - '--storage.tsdb.path=/prometheus'
  - '--web.console.libraries=/etc/prometheus/console_libraries'
  - '--web.console.templates=/etc/prometheus/consoles'
  - '--web.enable-lifecycle'
ports:
  - "9090:9090"
depends_on:
  - init_prometheus 
Vahid F
  • 377
  • 1
  • 7
  • 21
  • For any interested; the "command:" section in the "prometheus:" service block is not necessary.The only thing you need to add to an existing compose file is the "init_prometheus:" service and the "depends_on:" block to the existing Prometheus service entry. I have tried MANY solutions, this feels kludgy but is the only one which consistently works and doesn't require running Prometheus as root. – Danin Jul 26 '23 at 19:39
0

You are mounting folder from the container to your user space, prometheus cannot access it.

There has to be a better solution but the following worked for me:

 services:
  prometheus:
    image: prom/prometheus
    user: root