环境
阿里云服务器 ECS
macbookpro
docker --version :Docker version 17.03.2-ce, build f5ec1e2
ubuntu_16_0402_64_20G_alibase_20180409.vhd
登录云服务器
ssh root@11.11.11.11
安装Jenkins
docker run -d --name jenkins -p 8080:8080 -v $PWD:/var/lib/jenkins jenkinsci/jenkins:lts
# -p 本机端口:容器端口
# --name 容器别名
# -v $PWD:/var/lib/jenkins 将当前目录挂载到容器的 /var/lib/jenkins
# -d 后台运行
设置阿里云安全策略
阿里云控制台→云服务器 ECS→网络和安全→安全组→配置规则→添加安全组规则,配置如下
本机访问Jenkins 服务
11.11.11.11:8080
安装的时候遇到的问题:
使用docker ps 查看,Jenkins 没有起来
使用docker logs 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?
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?
原因:
需要修改下目录权限, 因为当映射本地数据卷时,/root/data/jenkins/目录的拥有者为root用户,而容器中jenkins user的uid为1000
重启:
docker start jenkins