Kubernetes(k8s)部署jenkins
docker 镜像的制作//java 的环境[root@master tmp]# tree java/java/├── dockerfile└── files├── apache-tomcat-8.5.54.tar.gz├── index.jsp├── install.sh //有执行权限├── jenkins-2.303.3.war└── jenkins-2.319.1.war1 directo
·
docker 镜像的制作
//java 的环境
[root@master tmp]# tree java/
java/
├── dockerfile
└── files
├── apache-tomcat-8.5.54.tar.gz
├── index.jsp
├── install.sh //有执行权限
├── jenkins-2.303.3.war
└── jenkins-2.319.1.war
1 directory, 6 files
//installs.sh
[root@master tmp]# cat java/files/install.sh
#!/bin/bash
rm -rf /etc/yum.repos.d/*
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-$(awk -F '"' 'NR==5{print $2}' /etc/os-release).repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
yum install -y java-1.8.0-openjdk
ln -s /usr/local/apache-tomcat-${version}/ /usr/local/tomcat
cp /opt/jenkins-2.319.1.war /usr/local/tomcat/webapps/
//index.jsp 测试
[root@master tmp]# cat java/files/index.jsp
cat > index.jsp <<EOF
<html>
<head>
<title>test page</title>
</head>
<body>
<%
out.println("goold");
%>
</body>
</html>
EOF
//java dockerfile 编写
[root@master tmp]# cat java/dockerfile
FROM centos
MAINTAINER JRE "xx 1@2.com"
ENV version 8.5.54
ENV PATH $PATH:/usr/local/tomcat/bin
ADD files/apache-tomcat-${version}.tar.gz /usr/local/
COPY files/jenkins-2.319.1.war /opt
COPY files/index.jsp /opt
COPY files/install.sh /tmp
RUN /tmp/install.sh
WORKDIR /usr/local/tomcat/bin
EXPOSE 8080
CMD ["/usr/local/tomcat/bin/catalina.sh", "run"]
//构建镜像
[root@master tmp]# docker build -t hyhxy0206/tomcat:v0.2 /tmp/java/
//开放端口
[root@master tmp]# docker run -dit -p 8080:8080 hyhxy0206/tomcat:v0.2
6bdaff9baa0a9e25e2abcaadfc8e6bc468c3736d34ed6703c1f44c19268a5559
//运行容器,添加jenkins
[root@master tmp]# docker exec -it 6bda /bin/bash
[root@6bdaff9baa0a bin]# cd ../webapps/ROOT/
[root@6bdaff9baa0a ROOT]# ls
RELEASE-NOTES.txt bg-middle.png index.jsp tomcat.png
WEB-INF bg-nav.png tomcat-power.gif tomcat.svg
asf-logo-wide.svg bg-upper.png tomcat.css
bg-button.png favicon.ico tomcat.gif
[root@6bdaff9baa0a ROOT]# rm -rf *
[root@6bdaff9baa0a ROOT]# cp ../jenkins-2.319.1.war .
[root@6bdaff9baa0a ROOT]# yum -y install unzip
[root@6bdaff9baa0a ROOT]# unzip jenkins-2.319.1.war
[root@6bdaff9baa0a ROOT]# ls
ColorFormatter.class css
JNLPMain.class executable
'LogFileOutputStream$1.class' favicon.ico
LogFileOutputStream.class help
META-INF images
'Main$FileAndDescription.class' jenkins-2.319.1.war
Main.class jsbundles
MainDialog.class robots.txt
WEB-INF scripts
bootstrap winstone.jar
[root@master tmp]# docker restart 6bdaff9baa0a
6bdaff9baa0a
//密码是
[root@master tmp]# docker exec -it 6bda /bin/bash
[root@6bdaff9baa0a bin]# cat /root/.jenkins/secrets/initialAdminPassword
d69ce3623fb849a9a72abab325a018ad
[root@6bdaff9baa0a bin]#
ip:8080 访问
//制作镜像tomcat:0.3版本
[root@master ~]# docker commit -p -c 'CMD ["/usr/local/tomcat/bin/catalina.sh", "run"]' 6bdaff9baa0a hyhxy0206/tomcat:v0.3
[root@master ~]# docker login
Authenticating with existing credentials...
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
[root@master ~]# docker push hyhxy0206/tomcat:v0.3
The push refers to repository [docker.io/hyhxy0206/tomcat]
db34599dc751: Pushing 52.55MB/506.9MB
ec5d05b8e7ff: Pushing 16.39MB/306.2MB
3dee58484c09: Pushed
0aa9bd528377: Pushed
2640b4ad9644: Pushed
75b54b1d4c4b: Pushed
74ddd0ec08fa: Pushing 11.51MB/231.3MB
更多推荐
已为社区贡献5条内容
所有评论(0)