把玩jenkins docker镜像遇到的volume权限问题
2017-06-21 12:41
417 查看
这两天在玩jenkins,但是在挂在数据卷的时候遇到了权限问题,如下,
docker启动命令
docker run -d -v /root/jenkins:/var/jenkins_home -P --name jenkins-server jenkins
这个命令看似没有什么问题,但容器就是启动不起来,执行
docker ps -a,查看
container,如下,
[root@esslog-shqs-6 ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 274d92964edb jenkins "/bin/tini -- /usr/lo" 2 minutes ago Exited (1) 2 minutes ago jenkins-server
接着执行
docker logs jenkins-server查看
container日志,如下
Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions? touch: cannot touch ‘/var/jenkins_home/copy_reference_file.log’: Permission denied
日志中出现了一个
Permission denied错误,,以我目前的功力还不清楚是什么问题造成的,但是在谈谈Docker Volume 之权限管理和持续集成(Continuous integration)两篇博客中找到了答案,在执行
docker run命令的时候增加一个
-u参数,如下改进后的命令,
docker run -d -v /root/jenkins:/var/jenkins_home -u 0 -P --name jenkins-server jenkins
这命令的意思是覆盖容器中内置的帐号,该用外部传入,这里传入
0代表的是root帐号Id。这样再启动的时候就应该没问题了。
如果按照上面做还是出现
Permission denied错误,那么可以检查一下
selinux状态,开启的情况下会导致一些服务安装、使用不成功。
查看selinux状态,
[root@localhost ~]# sestatus SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: targeted Current mode: enforcing Mode from config file: enforcing Policy MLS status: enabled Policy deny_unknown status: allowed Max kernel policy version: 28
临时关闭,
[root@localhost ~]# setenforce 0
永久关闭,可以修改配置文件/etc/selinux/config,将其中SELINUX设置为disabled,如下,
[root@localhost ~]# cat /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. #SELINUX=enforcing SELINUX=disabled # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted [root@rdo ~]# sestatus SELinux status: disabled
相关:
docker registry push错误“server gave HTTP response to HTTPS client”
在docker中使用mongo数据库,在局域网访问
在docker中使用mysql数据库,在局域网访问
参考文章:
http://www.cnblogs.com/99fu/p/6042744.html
https://yq.aliyun.com/articles/53990
http://blog.csdn.net/one_clouder/article/details/39224767
http://www.orcs.cc/post/6.html
阅读原文
相关文章推荐
- 把玩jenkins docker镜像遇到的volume权限问题
- Jenkins 构建Docker镜像执行shell脚本用户权限问题
- Docker 创建php 开发环境遇到的权限问题解决方案
- 运行docker时遇到的镜像问题
- 在阿里云上使用 Docker 并配置阿里云镜像加速器,结果遇到无daemon.json文件无法配置的问题
- 详解Docker创建php开发环境遇到的权限问题解决方案
- 使用DaoCloud加速docker镜像下载——修改daemon.json遇到的问题
- 【问题解决】docker中创建volume时,无访问权限
- VMware Harbor 使用过程中遇到的问题 1 -- 无法上传docker镜像
- 在搭建基于jenkins+maven+git+docker的全自动化部署时遇到的问题
- 拷贝文件到docker volume后出现的权限问题
- docker拉取mysql镜像遇到到问题及解决
- 新手的我在使用docker制作tomcat镜像时遇到环境变量问题
- 基于“基于dockerhub的jetty镜像的ossfs镜像”部署war包,遇到的文件夹读写权限被限制的问题解决方案
- 构建MySQL(5.6.22)Docker镜像遇到的问题
- Jenkins遇到问题一:jenkins配置权限不对导致无法登陆或者空白页面解决办法
- Docker-通过Docker ToolBox安装Docker可能会遇到的问题和如何通过Docker 拉取镜像
- 在sharepoint中浏览图片遇到的权限问题及解决办法
- Yii框架中使用SRBAC作为权限管理模块时遇到的问题
- 虚拟机安装tools的过程中遇到一个c header 问题(我的镜像是:ubuntu-10.10-desktop-i386.iso)