在docker中,以非root身份将文件写入安装的文件系统? [英] In docker, writing file to mounted file-system as non-root?

查看:87
本文介绍了在docker中,以非root身份将文件写入安装的文件系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有-v / home / dan:/ home / dan:rw的Docker容器。当容器将文件写入/ home / dan时,文件由主机文件系统中的root拥有。有没有一种方法可以使从容器写入装载卷的文件由主机文件系统上的某个任意用户拥有?

I have a docker container with a -v /home/dan:/home/dan:rw. When the container writes files to /home/dan, the files are owned by root in the host filesystem. Is there a way to make it so that files written from the container to the mounted volume are owned by some arbitrary user on the host filesystem?

推荐答案

编辑:自从我原来的回答说无法完成以来,这种情况已经改变。根据曼达克的答案:

this has changed since my original answer which said it couldn't be done. As per answer of Mandark:


使用 docker run 命令使用 -u 开关完成。

例如:


docker run -v /home/dan:/home/dan -u `id -u $USER` IMAGE

这篇关于在docker中,以非root身份将文件写入安装的文件系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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