By accessing the website and accepting the Cookie Policy, you agree to use the cookies provided by the Site in accordance with to analyze traffic, remember your preferences, and optimize your experience.
解决Docker容器没有权限写入宿主机目录
2021-02-04 17:39:51    533    0    0
emengweb

在应用docker容器的时候,更多的时候我们会把宿主机的目录挂载到docker容器中。
在宿主机的文件夹权限隶属于root时,我们需要将文件夹的权限用户进行 chown 设置,才能保证目录的内容的正常写入,下面是一个例子:

使用的是docker版本的jenkins,运行后,出现如下错误:

[root@localhost CICD]# docker logs -f jenkins 
touch: cannot touch '/var/jenkins_home/copy_reference_file.log': Permission denied
Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?

我jenkins挂载的目录是 /opt/jenkins/xxxxx,root 用户创建,而 jenkins user的uid为1000
所以需要进行 chown 设置,如下:

sudo chown -R 1000:1000 /opt/jenkins

然后重启容器,错误就没有了。

上一篇: 第三/四代谷歌网盘Clone术:Gclone/Fclone

下一篇: 提升UI设计的高级感

533 人读过
文档导航