Rui Nian
Rui Nian

Reputation: 2975

Permission denied on one docker container

I am new to docker and I am building a simple dashboard app with Loki and Grafana.

I am trying to change the Grafana setup file in the Grafana container, however, it says "Permission denied". I tried mkdir test in the container at multiple locations and they are all permission denied, so I know its a permission issue. For my entire repository, I have 4 separate containers. All other containers do not get permission denied, only the Grafana container. Furthermore, my old Ubuntu VM was corrupted, but the old VM also did not get permission denied, so I am not sure why the new one is.

I have tried running:

sudo chmod -R a+rwx repo

to provide permissions to everything. I checked all the volumes permissions by right-clicking them, and they are all "Create and delete files" for Owner, Group and Others.

On the docker container, I ran a permissions check and got: enter image description here

However, the other containers have similar permissions.

I also ran id on the container. For the container with no permissions, I got: enter image description here for the one that does not work.

The ones that do work return enter image description here

The entire docker-compose code can be found here:

version: "3"

networks:
  bypass:

services:

  loki:
    image: grafana/loki:2.4.0
    volumes:
      - ./admin/config:/mnt/config
      - ./data/loki:/mnt/loki
    ports:
      - "3100:3100"
    command: -config.file=/mnt/config/loki-config.yaml
    restart: unless-stopped
    networks:
      - bypass

  promtail:
    image: grafana/promtail:2.4.0
    volumes:
      - ./data/raw:/mnt/raw
      - ./data/log:/mnt/log
      - ./admin/config:/mnt/config
    command: -config.file=/mnt/config/promtail-config.yaml
    restart: unless-stopped
    networks:
      - bypass

  bypass:
    image: bypass:latest
    ports:
      - "8080:8080"
    volumes:
      - ./data/raw:/mnt/raw
      - ./data/log:/mnt/log
      - ./admin/config:/mnt/config
      - ./data/template:/mnt/template
    networks:
      - bypass

  grafana:
    image: grafana/grafana:8.2.5
    user: "1000"
    volumes:
      - ./data/grafana:/var/lib/grafana
      - ./data/log:/var/lib/temp_data
    restart: unless-stopped
    ports:
      - "3000:3000"
    networks:
      - bypass

Upvotes: 1

Views: 4785

Answers (1)

Rui Nian
Rui Nian

Reputation: 2975

The issue was under user. I tried specifying

user: "1000"

in the grafana docker-compose because when running id on my local machine, it says that the UID for the user and group are both 1000. Despite this, I had to change the user to

user: "0"

to replicate what I was seeing on the containers of my other services and it worked!

Upvotes: 2

Related Questions