1.拉取jenkins镜像,以2.222.3为例
docker pull jenkins/jenkins:2.222.3
2.启动jenkins容器
docker run -d --name jenkins2.222.3 -p 8080:8080 -p 50000:50000 -v /var/jenkins:/var/jenkins_home jenkins/jenkins:2.222.3
2.1若报touch: cannot touch '/var/jenkins_home/copy_reference_file.log': Permission denied,则需要修改下目录权限, 因为当映射本地数据卷时,/var/jenkins目录的拥有者为root用户,而容器中jenkins user的uid为1000
执行如下命令即可:
chown -R 1000:1000 /var/jenkins
3打开ip+8080端口,输入初始密码,由于是-d后台运行,可输入以下命令查看容器内部输出日志
docker logs -f jenkins2.222.3