在Easypack中的Alpine容器中,我们将会挑选一些非常流行的工具进行自定义设定以及进行最佳实践的整理,基本思路都是在官方镜像的最新版本之上进行强化。本次为持续集成利器Jenkins。
常用环境变量设定如下所示:
环境变量 | 说明 |
---|---|
JENKINS_MODE | JENKINS模式,可设定为master或者slave |
JENKINS_ADMIN_ID | 登陆用户ID |
JENKINS_ADMIN_PW | 登陆用户密码 |
JENKINS_MASTER_URL | slave方式启动时jnlpurl设定 |
JENKINS_SLAVE_SECRET | slave方式启动时secret设定 |
JENKINS_SLAVE_WORKDIR | slave方式启动时工作目录设定 |
另外,JENKINS_OPTS和JAVA_OPTS同样可用
与dockerhub结合,自动构建,自由更新。
项番 | 当前版本 | jenkins官方LTS稳定最新版本 |
---|---|---|
版本 | 2.150.1 | 2.150.1 |
命令:docker pull liumiaocn/jenkins:2.150.1
[root@liumiaocn master]# tree
.
├── data
└── docker-compose.yml
1 directory, 1 file
[root@liumiaocn master]# cat docker-compose.yml
version: '2'
services:
# jenkins service based on Jenkins LTS version
jenkins:
image: liumiaocn/jenkins:2.150.1
ports:
- "32002:8080"
- "50000:50000"
environment:
- JENKINS_ADMIN_ID=root
- JENKINS_ADMIN_PW=liumiaocn
- JENKINS_MODE=master
volumes:
- ./data/:/data/jenkins
restart: "no"
[root@liumiaocn master]#
启动&确认
[root@platform master]# docker-compose up -d
Creating network "master_default" with the default driver
Creating master_jenkins_1 ...
Creating master_jenkins_1 ... done
[root@platform master]# docker-compose ps
Name Command State Ports
-------------------------------------------------------------------------------------------------------------
master_jenkins_1 /bin/tini -- /usr/local/bi ... Up 0.0.0.0:50000->50000/tcp, 0.0.0.0:32002->8080/tcp
[root@platform master]#
命令:docker run -p 32002:8080 -p 50000:50000 -e JENKINS_ADMIN_ID=root -e JENKINS_ADMIN_PW=liumiaocn -e JENKINS_MODE=master -v /tmp/data:/data/jenkins --name jenkins liumiaocn/jenkins:2.150.1
使用上述32002端口和root/liumiaocn的初始管理用户进行登陆
因为plugin等已经在初始化时进行了安装,此处直接点击X跳过即可
点击Start using jenkins即可开始使用了
[root@liumiaocn ~]# docker exec -it master_jenkins_1 sh
/ # /usr/local/share/maven/bin/mvn -v
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T18:41:47Z)
Maven home: /usr/local/share/maven
Java version: 1.8.0_121, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-1.8-openjdk/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-693.el7.x86_64", arch: "amd64", family: "unix"
/ #
/ # docker -v
Docker version 18.09.0, build 4d60db4
/ #
/ # kubectl version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.12", GitCommit:"c757b93cf034d49af3a3b8ecee3b9639a7a11df7", GitTreeState:"clean", BuildDate:"2018-12-19T11:16:52Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
...省略
/ #
/ # robot --version
Robot Framework 3.1.1 (Python 2.7.15 on linux2)
/ #
项目 | URL |
---|---|
Jenkins-Alpine容器 | https://github.com/liumiaocn/easypack/tree/master/containers/alpine/jenkins |