Jenkins Docker 安装

服务器

我用的是腾讯云得服务器,默认安装了docker

参考

https://www.cnblogs.com/cxt618/p/15021471.html
https://www.cnblogs.com/onesea/p/15745449.html
http://www.360doc.com/content/20/1008/15/61746833_939429398.shtml

准备工作

1.关闭防火墙和SeLinux

systemctl stop firewalld && systemctl disable firewalld
setenforce 0
sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/sysconfig/selinux

2.禁用swap交换分区

swapoff -a && sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/sysconfig/selinux 
````
3.配置镜像加速
````
# 这里使用的是我的阿里云镜像加速,可以自己去阿里云配置一个
mkdir -p /etc/docker 
tee /etc/docker/daemon.json <<-'EOF'
{
    "registry-mirrors": ["https://mxdu1aof.mirror.aliyuncs.com"], 
    "exec-opts": ["native.cgroupdriver=systemd"]
}
EOF
````

6.配置ipv4.ip_forward
````
vim /etc/sysctl.conf

# 在sysctl.conf的最后加入下面这一行
net.ipv4.ip_forward=1
```` 7.重新启动守护进程并重启docker ```` systemctl daemon-reload && systemctl restart docker ```` ####安装jinkens 1、下载jenkins镜像 从docker_hub官网找jenkins的镜像源,然后找到下载源的命令如下 ```` $ docker pull jenkins/jenkins ```` 2、启动jenkins容器 ```` 新建/home/jenkins_home并设置文件权限 $ mkdir /var/jenkins_home $ sudo chown 777 /var/jenkins_home $ sudo chmod -R 777 /var/jenkins_home/ $ docker run -d -p 8080:8080 -p 50000:50000 -v /var/jenkins_home:/var/jenkins_home -u 0 -v /var/run/docker.sock:/var/run/docker.sock --name jenkins docker.io/jenkins/jenkins ```` 3、打开8080地址, 看到让你输入jenkins初始登陆密码,通过如下命令获取 ``` $ docker exec jenkins tail /var/jenkins_home/secrets/initialAdminPassword ``` 然后复制密码去登陆,然后安装推荐的插件,安装好后设置jenkins登陆账号密码 4、到插件管理中下载Nodejs以及Generic Webhook Trigger Plugin插件,重新启动以后在全局工具配置中配置node版本 5、新建流程 ![图片.png](https://upload-images.jianshu.io/upload_images/1480521-3ab266e0e1517729.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ![图片.png](https://upload-images.jianshu.io/upload_images/1480521-dafd26157423c24f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ![图片.png](https://upload-images.jianshu.io/upload_images/1480521-8f22470d1062b5a7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ![图片.png](https://upload-images.jianshu.io/upload_images/1480521-ea6915c53f25c66c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ![图片.png](https://upload-images.jianshu.io/upload_images/1480521-f129f795407b2b53.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ![图片.png](https://upload-images.jianshu.io/upload_images/1480521-47893349f829d212.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ![图片.png](https://upload-images.jianshu.io/upload_images/1480521-92b09384b2e4a767.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ```` echo $PATH node -v npm -v cd /var/jenkins_home/workspace/smart_factory npm install -g yarn yarn install npm run build node -v npm -v ```` 最后测试验证!!!!!!!!! ![图片.png](https://upload-images.jianshu.io/upload_images/1480521-69bfd1ad44be451e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

你可能感兴趣的:(Jenkins Docker 安装)