如何在docker中以非root用户身份写入卷容器? [英] How do I write to a volume container as non-root in docker?
本文介绍了如何在docker中以非root用户身份写入卷容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何挂载非root容器用户可写的卷?我可以将非root用户拥有的卷或将权限设置为777。
How do I mount a volume writable by a non-root container user? I am ok with either the volume being owned by the non-root user or permissions being set to 777.
Dockerfile:
Dockerfile:
FROM alpine
RUN adduser -D myuser
USER myuser
构建映像:
docker build -t example .
运行图像,查看/ app用户不可写
Run image, see /app unwritable by user
% docker run -i -t -v myapp:/app example /bin/sh
/ $ whoami
myuser
/ $ ls -lha / | grep app
drwxr-xr-x 2 root root 4.0K Nov 12 21:01 app
/ $
我们可以看到该应用程序是全局可读的,但只能由root用户写入。
We can see app is globally readable but only writable by root.
推荐答案
尚不支持,并在问题2259 中进行了研究。
会影响其他图像像 docker-java 。
That is not yet supported, and is studied in issue 2259.
That affect other images like docker-java.
基本上,您必须小丑并复制(使用正确的用户)卷中的数据,这不是很方便。
Basically, you have to chown and copy (with the right user) your data in the volume, which is not very convenient.
这篇关于如何在docker中以非root用户身份写入卷容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文