1.下载镜像
docker pull jenkins/jenkins
2.创建用户和数据目录并授权
useradd -u 1000 jenkins -M -s /sbin/nologin
mkdir /data/jenkins/ -p
chown -R jenkins:jenkins /data/jenkins/
3.运行镜像
docker run \
--name jenkins \
-p 8080:8080 -p 50000:50000 \
--privileged=true \
--user root \
-v /usr/bin/docker:/usr/bin/docker \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /data/jenkins/:/var/jenkins_home \
-d jenkins/jenkins
4.安装插件
tar zxf jenkins_plugins.tar.gz
mv plugins /data/jenkins/
chown -R jenkins:jenkins /data/jenkins/
docker restart jenkins
5.查看默认登录密码
[root@docker-200 /opt]#cat /data/jenkins/secrets/initialAdminPassword
9f9534d8edd646ea89011111b81ffbc0
[root@docker-200 /opt]#