Docker在Centos下使用Dockerfile构建远程Tomcat和Jenkins镜像

Posted 君临

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Docker在Centos下使用Dockerfile构建远程Tomcat和Jenkins镜像相关的知识,希望对你有一定的参考价值。

镜像构建准备环境原料

构建CentOS Docker tomcat镜像

Dockerfile文件内容:

FROM centos:latest
MAINTAINER boonya <boonya@sina.com> 
# now add java and tomcat support in the container 
ADD jdk-8u121-linux-x64.tar.gz /usr/local/ 
ADD apache-tomcat-8.5.16.tar.gz /usr/local/ 
# ADD tomcat-users.xml /usr/local/apache-tomcat-8.5.16/conf/tomcat-users.xml
# configuration of java and tomcat ENV 
ENV JAVA_HOME /usr/local/jdk1.8.0_121 
ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar 
ENV CATALINA_HOME /usr/local/apache-tomcat-8.5.16 
ENV CATALINA_BASE /usr/local/apache-tomcat-8.5.16 
ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/bin 
# container listener port 
EXPOSE 8080 
# startup web application services by self 
CMD /usr/local/apache-tomcat-8.5.16/bin/catalina.sh run

 

Dockerfile构建命令:

docker build -t boonyadocker/centos-tomcat:allow-remote .

 

构建CentOS Docker jenkins镜像

Dockerfile文件内容:

FROM centos:latest
MAINTAINER boonya <boonya@sina.com> 
# now add java and tomcat support in the container 
ADD jdk-8u121-linux-x64.tar.gz /usr/local/ 
ADD apache-tomcat-8.5.16.tar.gz /usr/local/ 
ADD apache-maven-3.3.9-bin.tar.gz /usr/local/ 
ADD jenkins.war /usr/local/apache-tomcat-8.5.16/webapps/
# ADD tomcat-users.xml /usr/local/apache-tomcat-8.5.16/conf/tomcat-users.xml
# configuration of java and tomcat ENV 
ENV JAVA_HOME /usr/local/jdk1.8.0_121 
ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar 
ENV CATALINA_HOME /usr/local/apache-tomcat-8.5.16 
ENV CATALINA_BASE /usr/local/apache-tomcat-8.5.16 
ENV MAVEN_HOME /usr/local/apache-maven-3.3.9
ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/bin:$MAVEN_HOME/bin 
# container listener port 
EXPOSE 8080 
# startup web application services by self 
CMD /usr/local/apache-tomcat-8.5.16/bin/catalina.sh run

 

Dockerfile构建命令:

docker build -t boonyadocker/centos-jenkins:allow-remote .

 

镜像已上传:https://hub.docker.com/

以上是关于Docker在Centos下使用Dockerfile构建远程Tomcat和Jenkins镜像的主要内容,如果未能解决你的问题,请参考以下文章

Docker——Dockerfile(构建自己的CentOS镜像和Tomcat镜像)并打包镜像发布上线

Docker-compose容器

Docker-compose容器

Docker-compose容器

openresty中的set_by_lua&os.getenv:alpine docker container

Centos7.6下使用docker方法安装stf