环境
docker_host | 192.168.0.1 |
jenkins_host | 192.168.0.2 |
jenkins_host构建完成后把jar发布到docker_host,再通过dockerfile自动构建镜像,运行镜像
1 Jenkins安装
AWS EC2安装Jenkins:AWS EC2 + JDK11 + Jenkins-CSDN博客
AWS EC2上Docker安装Jenkins:Jenkins安装 :Aws EC2下Docker镜像安装-CSDN博客
2 插件安装
安装Docker Pipeline,Docker Commons,Docker和Publish Over SSH插件
3 docker配置
1) docker配置
docker_host
$ sudo vi /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H fd:// -H --containerd=/run/containerd/containerd.sock $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_ADD_RUNTIMES
-H fd://后面增加-H tcp://0.0.0.0:2376,修改成
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2376 --containerd=/run/containerd/containerd.sock $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_ADD_RUNTIMES
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
2) jenkins配置docker
Dashboard -> 系统管理 -> Clouds,点击New Cloud
点击Create
Docker Host URI输入tcp://192.168.0.1:2376,点击Test Connection,连接测试成功
4 SSH Server配置
Dashboard -> 系统管理 -> System,下拉到Publish over SSH,SSH Servers下点新增
填写docker_host的ssh的登录账号和密码,点击Test Configuration,显示Success