一、安装部署docker
1、安装docker-ce
2、配置docker镜像加速
[root@docker ~]# cat /etc/docker/daemon.json
{
"registry-mirrors": [
"https://dockerhub.icu",
"https://docker.registry.cyou",
"https://docker-cf.registry.cyou",
"https://dockercf.jsdelivr.fyi",
"https://docker.jsdelivr.fyi",
"https://dockertest.jsdelivr.fyi",
"https://mirror.aliyuncs.com",
"https://dockerproxy.com",
"https://mirror.baidubce.com",
"https://docker.m.daocloud.io",
"https://docker.nju.edu.cn",
"https://docker.mirrors.sjtug.sjtu.edu.cn",
"https://docker.mirrors.ustc.edu.cn",
"https://mirror.iscas.ac.cn",
"https://docker.rainbond.cc",
"https://registry.docker-cn.com",
"https://hub-mirror.c.163.com"
]
}
### 重启服务
systemctl restart docker
二、安装部署docker-compose
1、docker-compose资源包下载
之前的博客有分享docker-compose资源包
docker-compose安装包https://blog.csdn.net/qq_48472816/article/details/141826124?spm=1001.2014.3001.5501
2、部署docker-compose
执行下列操作前请上传docker-compose-linux-x86_64到虚拟机
mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version
三、部署jenkins项目
1、创建项目目录
version: '3'
services:
jenkins:
image: jenkins/jenkins:latest
ports:
- "50000:50000"
- "8080:8080"
volumes:
- /compose/jenkins/jenkins_mount:/var/jenkins_home
- /etc/localtime:/etc/localtime
2、运行项目
docker-compose -f docker-compose.yml up -d
查看运行的jenkins容器
3、初始化jenkins
访问:http://192.168.147.20:8080
进入容器,查看初始密码
docker exec -it ab56e611a388 /bin/bash
jenkins@ab56e611a388:/$ cat /var/jenkins_home/secrets/initialAdminPassword
5824d3311f494ba4ad06ea740a0bd5fb
安装推荐插件
创建新管理员用户,密码:Aa123456!
按提示完成后续操作
至此,使用docker-compose部署jenkins完成。