大网数据广告活动
服务器运维问答

ownership of created volumes in portainer

· 52CE 我爱测

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 thos…

问题原文

原帖链接 · Mael Abgrall · CC BY-SA 4.0

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 · CC BY-SA 4.0

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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-04-11)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。