前置条件: 已经正常安装docker
https://www.cnblogs.com/xiaojf/p/10826473.html
docker 设置阿里云加速
https://www.cnblogs.com/xiaojf/p/10837170.html
docker 下载jenkins 最新镜像
[root@localhost workspace]# docker pull jenkins/jenkins:lts
查看jenkins镜像描述
[root@localhost workspace]# docker inspect images
启动一个jenkins 容器(注意name 和 卷挂载名称要保持一致)
sudo docker run --restart=always -d --name jenkins -p 8080:8080 -p 50000:50000 -u root \
-v /usr/local/workspace/jenkins_home:/var/jenkins_home \
-v /usr/local/soft/maven:/usr/local/maven \
-v /usr/local/soft/jdk:/usr/local/jdk \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/bin/docker:/usr/bin/docker \
jenkins/jenkins:lts
如果一致没启动, 则查看容器logs
docker logs jenkins
如果发现加载卷的permission 问题, 则设置selinux
临时关闭, [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
打开浏览器访问jenkins 首页 http://192.168.25.130:8080/
进入jenkins 容器内, 获取账号密码
[root@localhost workspace]# docker exec -it jenkins bash; jenkins@1eec6f81f2f5:/$ cat /var/jenkins_home/secrets/initialAdminPassword 70cfad46179d4654a53988f728b2ea82 jenkins@1eec6f81f2f5:/$
输入密码
安装推荐的插件
永久关闭,可以修改配置文件/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
作者:简书首席码农
链接:https://www.jianshu.com/p/4d50f0da9ef6
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。