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
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With