Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

2.2K
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda