2

I'm new to using Docker & Portainer.

I created a stacks using portainer, and added persistent volumes for the different apps through the same docker-compose.

My issue is that when editing and then saving the files created in those volumes (for example Nginx configuration) I get a "permission denied" to write this file.

When I'm going in the folder, and type ls -l to check the ownership, I see that every folder used by portainer is owned by the root user.

Is that normal behaviour? Am I missing a configuration under portainer or should I change the ownership of those volumes to my user?

note: I'm using portainer 1.23.1, docker 19.03.2 and ubuntu 19.10. This is a personal homelab project but I'm also interested to know how this would do in production.

Mael Abgrall
  • 131
  • 4

2 Answers2

1

After a few years of using docker and docker compose, I got a notification that this question was still active

This issue is due to docker using by default the root user to run containers (unless the container has already a specified user).

To prevent this issue, the container should be run with the same user as the one on the OS using the --user="" flag (or user: "" in docker compose) and specifying the uid

ex:

services:
  mycontainer:
    image: myimage:latest
    user: "1000"

To get the user uid, you only need to run the command id $USER

Mael Abgrall
  • 131
  • 4
0

Curious, ran into the same problem.

But just writing user: "1000" doesn't solve the problem (1000 - is my uid/gid)

It only helps:

    environment:
      - PUID=1000
      - PGID=1000

So far, I don't understand what causes this behavior...


I think I figured out what the problem is:

leni8ec
  • 1
  • 2
  • "environment" is a specificity of the application you are using right now. As far as I know, those two variables are only used by Linuxserver.io images. Your solution might not work with an image not made by linuxserver. have a look here: https://serverfault.com/a/986411/569315 – Mael Abgrall Jan 11 '23 at 21:54