Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

2.2K
Vistas
docker-compose opening storage failed: permission denied error on running

I'm trying to execute my docker-compose.yml file which contains prometheus and grafana configurations.

Here is my docker-compose.yml file:

version: '2'
services:
  prometheus:
    image: prom/prometheus
    ports:
      - 9090:9090
    volumes:
      - /prometheus:/prometheus
    command: 
      - --config.file=/etc/prometheus/prometheus.yml 


  grafana:
    image: grafana/grafana
    ports:
      - "3000:3000"
    volumes:
      - /var/lib/grafana:/var/lib/grafana

Whenever I enter docker-compose -f docker-compose.yml up command to run it, I face with these kind of errors about permission:

prometheus_1  | level=error ts=2019-06-30T16:14:42.690Z caller=main.go:723 err="opening storage failed: lock DB directory: open /prometheus/lock: permission denied" 
prometheus_1  | level=error ts=2019-06-30T16:26:11.897Z caller=main.go:723 err="opening storage failed: mkdir data/: permission denied"

I don't know how to solve this problem, I already have searched over github issues and the other stackoverflow's questions, but unfortuntely none of them help!

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

If you don't need access from the host to these volume files, use a named volume instead of a host mount. Docker will initialize the contents of the named volume, including the permissions and ownership, avoiding permission issues like this:

version: '2'

volumes:
  prometheus:
  grafana:

services:
  prometheus:
    image: prom/prometheus
    ports:
      - 9090:9090
    volumes:
      - prometheus:/prometheus
    command: 
      - --config.file=/etc/prometheus/prometheus.yml 

  grafana:
    image: grafana/grafana
    ports:
      - "3000:3000"
    volumes:
      - grafana:/var/lib/grafana

For a general solution to solve permission issues with host mounts, the fix-perms script in my docker-base image can be used, along with an entrypoint and changes to how the container is started, to dynamically adjust the userid inside the container to match that of the volume mount.

over 4 years ago · Santiago Trujillo Denunciar

0

My docker-compose up command continually returned the following:

err="opening storage failed: lock DB directory: open /prometheus/lock: permission denied"

The problem is the folder structure/files on your local machine have the incorrect file permissions and when the docker container is fired up it is unable to write to the specified location.

I fixed this by recursively chown-ing the folder with the following command:

sudo chown -R nobody:nogroup <local path>

an example, my volumes section in my docker-compose.yml looked like this:

volumes:
  - /home/user/docker-volumes/prometheus:/prometheus

The colon signifies the separation of local file path : docker container file path. Applying my previous chown example above results in the following:

sudo chown -R nobody:nogroup /home/user/docker-volumes/prometheus

My docker-compose up no longer fails with permission denied!

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda