获得权限被拒绝,用于更改创建的文件和文件夹的权限

时间:2017-10-05 11:45:13

标签: dockerfile

我使用'hyperledger / fabric-couchdb:x86_64-1.0.2'图像在openshift上部署。 我得到了'/opt/couchdb/etc/local.d'的许可被拒绝了,尽管我已经为上述路径绘制了持久音量。

要解决此问题,我尝试通过创建自己的docker镜像来更改'hyperledger / fabric-couchdb:x86_64-1.0.2'中定义的权限。

我创建了具有以下内容的Dockerfile。

FROM hyperledger/fabric-couchdb:x86_64-1.0.2
RUN chgrp -R 0 /opt/couchdb/etc/local.d && chmod -R g=u /opt/couchdb/etc/local.d 

但是当我尝试使用'docker build'命令构建此图像时,我得到了以下错误。

docker build . -t deepakmule/fabric-couchdb:x86_64-1.0.2
Sending build context to Docker daemon 2.048 kB
Step 1/2 : FROM hyperledger/fabric-couchdb:x86_64-1.0.2
 ---> 3f922f54bd68
Step 2/2 : RUN chgrp -R 0 /opt/couchdb/etc/local.d && chmod -R g=u     /opt/couchdb/etc/local.d
 ---> Running in f06a386ecb01
chgrp: changing group of '/opt/couchdb/etc/local.d/local.ini': Operation not     permitted
chgrp: changing group of '/opt/couchdb/etc/local.d': Operation not permitted
The command '/bin/sh -c chgrp -R 0 /opt/couchdb/etc/local.d && chmod -R g=u     /opt/couchdb/etc/local.d' returned a non-zero code: 1

1 个答案:

答案 0 :(得分:0)

我猜这里有点:

上游Dockerfile可能有USER命令。所以之后的所有命令都在此用户下运行。您可以通过在USER root命令之前添加chgrp来解决此问题。之后添加另一个USER命令(检查上游Dockerfile设置了哪个用户。)

相关问题