Jenkins 2019 in Docker(1)Install Single App in Docker
You can find the Docker information here https://hub.docker.com/r/jenkins/jenkins
I like this command to get the LTS version
> docker pull jenkins/jenkins:lts
Then I prepare this Makefile to make it simple
PORT=9091
IMAGE=docker.io/jenkins/jenkins
TAG=lts
NAME=jenkins-$(PORT)
run:
docker run -d -p $(PORT):8080 -p 50000:50000 -v $(shell pwd)/jenkins:/var/jenkins_home --name $(NAME) $(IMAGE):$(TAG)
clean:
docker stop ${NAME}
docker rm ${NAME}
Start the Jenkins on my Local
>make run
Visit the UI
http://localhost:9091
Go to my directory and find the password there jenkins/secrets/initialAdminPassword
This nice command can run on the host machine to cat the content in side docker application
> docker exec jenkins-9091 cat /var/jenkins_home/secrets/initialAdminPassword
2aca09ea79f041edxxxxx
Install the suggested plugins, the LTS version is Jenkins 2.150.2
The installation is cool.
Go inside the docker node
> docker exec -it -u root jenkins-9091 bash
The war package is here in side the docker
/usr/share/jenkins/jenkins.war
Upgrade the war package if we need. Download the latest war
> wget http://mirrors.jenkins.io/war/latest/jenkins.war -P install/
Copy my war package there
> docker cp install/jenkins.war jenkins-9091:/usr/install/
Replace the war with the latest one
> cd /usr/share/jenkins/
> cp jenkins.war jenkins.war.bak
> cp /usr/install/jenkins.war /usr/share/jenkins/jenkins.war
Restart the Jenkins. Jenkins is running there
> java -Duser.home=/var/jerkins_home -jar /usr/share/jenkins/jenkins.war --httpPort=9090
Restart the jenkins
http://localhost:9091/restart
After upgrade, the version is Jenkins ver. 2.160
Use Generic Way to Run in Docker
start.sh to start the jenkins process
#!/bin/sh -ex
cd /tool/
java -Duser.home=/var/jenkins_home -jar jenkins.war
Dockerfile to prepare all dependencies
#Set Up Jenkins CI
#Prepre the OS
FROM centos:7
MAINTAINER Carl Luo <luohuazju@gmail.com>
#install the software
RUN yum -y update
RUN yum install -y java-1.8.0-openjdk-devel
#install jenkins
RUN mkdir -p /tool/
ADD install/jenkins.war /tool/
WORKDIR /tool/
#start the application
EXPOSE 8080 50000
RUN mkdir -p /app/
ADD start.sh /app/
WORKDIR /app/
CMD [ "./start.sh" ]
Makefile to summarize all the commands
PORT=9092
IMAGE=sillycat/public
TAG=lablue-jenkins-generic
NAME=jenkins-generic-$(PORT)
prepare:
wget http://ftp-nyc.osuosl.org/pub/jenkins/war-stable/2.150.2/jenkins.war -P install/
docker-context:
build: docker-context
docker build -t $(IMAGE):$(TAG) .
run:
docker run -d -p $(PORT):8080 -p 50000:50000 -v $(shell pwd)/jenkins_home:/var/jenkins_home --name $(NAME) $(IMAGE):$(TAG)
clean:
docker stop ${NAME}
docker rm ${NAME}
logs:
docker logs ${NAME}
jenkins_home is the backup and restore directory we need to care about.
References:
https://www.jianshu.com/p/0391e225e4a6
http://www.sunlins.cn/2018/11/19/%E3%80%90jenkinsdocker%E3%80%9102-%E5%8D%87%E7%BA%A7docker%E6%96%B9%E5%BC%8F%E5%AE%89%E8%A3%85jenkins%E7%9A%84%E7%89%88%E6%9C%AC/
https://hub.docker.com/_/jenkins/
分享到:
相关推荐
使用 Docker 安装 Jenkins,可以使用以下命令:docker run --name jenkins -u root --rm -d -p 8080:8080 -p 50000:50000 -v /var/jenkins_home:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock ...
jenkins教程+docker容器实际项目实战教程.pdf jenkins教程+docker容器实际项目实战教程.pdf
Gitllab+Jenkins+Docker+Harbor 自动化部署流程 一、 版本控制系统 Gitllab Gitllab 是一个基于 web 的 Git 仓库管理系统,提供了一个强大且灵活的平台来管理 Git 项目。 Gitllab 允许用户创建、管理和共享 Git ...
项目基本结构是SpringBoot,集成了docker-maven插件实现build完的镜像上传到私服,然后用 Jenkins构建实现docker集群一键自动化部署
基于Jenkins+Gitlab+Docker实现SpringBoot项目自动部署 本文主要介绍了基于Jenkins、Gitlab和Docker实现SpringBoot项目自动部署的方法。下面将从Jenkins的安装、配置到自动化构建和部署的整个过程进行详细说明。 ...
1)根据官方链接操作即可: https://jenkins.io/zh/doc/book/installing/ docker run \ -u root \ --rm \ -d \ -p 18080:8080 \ -p 50000:50000 \ -v jenkins-data:/var/jenkins_home \ -v /var/run/docker....
触发jenkins自动pull代码,通过maven编译、打包,然后通过执行shell脚本使docker构建镜像并push到私服(或者阿里云)仓库,此操作完成后jenkins服务器上再执行SSH命令登录到部署服务器,docker从仓库(私服)拉取...
带有Docker-in-Docker的Jenkins带有Docker-in-Docker的Jenkins容器映像是同时包含Jenkins和Docker-in-Docker的标准化连续集成环境。 这意味着它具有易于运输的Docker容器的所有优点,此外还具有从内部构建Docker容器...
jenkins-pipeline-docker, 带有Jenkins管道插件和 Docker的容器构建环境 采用Jenkins管道插件和 Docker的容器环境。这里代码与这里博客帖子相关:...
jenkins部署包 docker image
Jenkins mavn git docker-compose swarm 构建持续集成及一键式部署
Docker中的Jenkins附加了本地Docker注册表目的如果您在PC上使用Jenkins,您很可能会注意到启动后运行第一次Jenkins作业所花费的时间。 在此期间,Jenkins中的Docker提取在Jenkins文件中指定的映像。 每次Docker Dind...
##背景:jenkins部署在容器中,无法利用docker执行操作,通过ssh将jar包和当前路径下的dockerfile推送到指定服务器目录上,使用脚本进行构
使用 yum install 命令安装 Docker,然后查看仓库中 Docker 的版本,最后更新缓存并安装指定版本的 Docker。 3. 启动 Docker 使用 systemctl 命令启动 Docker,然后启用 Docker 使其在系统启动时自动启动。 4. ...
注意:最新版本的Jenkins官方Docker镜像缺少docker二进制文件所依赖的运行库libltdl,需要使用apt install libltdl-dev进行安装 其他:由于Jenkins Workspace中的文件均为临时性文件,当磁盘负担较重时可以使用-v /...
Jenkins Docker and DevOps The Innovation Catalysts,Jenkins Docker and DevOps The Innovation Catalysts
详细讲解Jenkins 结合Docker的 持续集成方案,包含大量的实践案例,适合项目发布人员和配管人员学习。
1.拉取3Jenkins镜像 docker pull jenkins/jenkins 2.查看镜像文件 docker images 3.创建Jenkins挂载目录并授权权限 创建:mkdir -p /usr/local/jenkins/data 授权:chmod -R 777 /usr/local/jenkins/data ...
gitlab+jenkins+docker自动化部署脚本,采用shell与python开发,其中python部分均为封装成型的逻辑,只接受shell传参就能完成项目构建
通过Jenkins完成docker的容器升级,镜像打包,上传仓库