Docker容器创建由root拥有的目录,我需要它们由1000:1000拥有 [英] Docker container creating directories owned by root, I need them owned by 1000:1000

查看:255
本文介绍了Docker容器创建由root拥有的目录,我需要它们由1000:1000拥有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我试图创建docker映像,但设法成功了.它是qBittorrent,一切正常,直到开始下载文件.所有qBits目录都归 1000:1000 拥有,但是一旦它开始下载文件,我的docker-host机器就会说该文件夹归 root:root .

So, I'm trying to get into creating docker images and I managed to get one going. It was qBittorrent, everything went fine until it started downloading files. All of qBits' directories are owned by 1000:1000 but as soon as it starts downloading a file, my docker-host machine says that the file folder is owned by root:root.

如何确定容器创建的所有内容均归 1000:1000 所有?

How can I make sure that everything the container creates is owned by 1000:1000?

我需要拥有它,因为其他Docker容器(例如Radarr)需要访问文件以导入它们,而现在我遇到权限错误.
我尝试在主机上执行 chown -r setgid ,但是文件一直由root创建和拥有...
我愿意接受所有建议:)谢谢!

I need it to be owned by that because other Docker containers, such as Radarr, need to access the files to import them and right now I'm getting permissions errors.
I've tried doing a chown -r and setgid on the host machine but the files keep getting created and owned by root...
I'm open to all suggestions :) Thanks!

我的Dockerfile:

My Dockerfile:

https://github.com/TheCreatorzOne/qbittorrent/blob/master/Dockerfile

推荐答案

已设法对其进行修复.该修复程序包括使用Dockerfile添加新用户.用户会自动收到1000:1000的UID和GID,但如果需要可以将其交换给其他人...

Managed to get it fixed up. The fix included adding a new user using the Dockerfile . The user automatically receives 1000:1000 as UID and GID but that can be swapped for others if so desired...

然后使用USER命令以用户身份运行Dockerfile

The Dockerfile is then run as the user with the USER command

USER使用的所有目录都必须是chown -R,并且必须是chmod 2775 -R(或任何其他目录,但前面必须是2或4,以便它们可以从主机文件夹继承权限)

All the directories the USER uses need to be chown -R and to be chmod 2775 -R (or any other, but either 2 or 4 in front so that they inherit permissions from the host folder)

还要确保您公开并创建所有需要的卷,否则qbittorrent将不会启动.在这里创建/Downloads/temp是必不可少的,否则会出错,因为它无法以root用户身份运行而无法创建自己的文件.

Also make sure that you expose and create all needed volumes or else qbittorrent will not start. Creating a /Downloads/temp was essential here or else it gave an error because it couldn’t create its own because it’s not running as root.

Dockerfile在这里可用: https://github.com/TheCreatorzOne/qbittorrent/blob/master/Dockerfile

The Dockerfile is available here: https://github.com/TheCreatorzOne/qbittorrent/blob/master/Dockerfile

PlexGuide自动化项目中使用了Ansible文件,因此可以在其中查看.

The Ansible file is used in the PlexGuide Automation Project, so it is available to look at there.

这篇关于Docker容器创建由root拥有的目录,我需要它们由1000:1000拥有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆