文档章节

制作tomcat docker镜像

caol
 caol
发布于 2017/05/08 14:51
字数 1098
阅读 71
收藏 0

##写在前面 tomcat和jdk是指定的版本,系统环境是Centos7。需要把源代码集成到镜像中。

##编写Dockerfile

# 基于centos:7 制作镜像
FROM centos:7
MAINTAINER  "cary <accaolei@gmail.com>"
ADD ./soft/tomcat.tar.gz   /usr/local/
ADD ./soft/jdk-7u80-linux-x64.tar.gz   /usr/local/    

WORDIR /usr/local/
RUN mv apache-tomcat-7.0.73 tomcat

#添加代码和配置文件
#ADD ./soft/catalina.sh /usr/local/tomcat/bin/
#ADD ./soft/server.xml /usr/local/tomcat/conf/
#RUN rm -rf /usr/local/tomcat/webapps/*
ADD ./soft/app-share /usr/local/tomcat/webapps/

#设置a环境变量
ENV JAVA_HOME=/usr/local/jdk1.7.0_80

ENV JRE_HOME=/usr/local/jdk1.7.0_80/jre
ENV PATH=$PATH:/usr/local/jdk1.7.0_80/bin
ENV CLASSPATH=./:/usr/local/jdk1.7.0_80/lib:/usr/local/jdk1.7.0_80/jre/lib
ENV TOMCAT_HOME=/usr/local/tomcat
ENV CATALINA_HOME=/usr/local/tomcat
# 赋予可以执行权限
RUN chmod u+x /usr/local/tomcat/bin/*.sh

#开发端口
EXPOSE 8080
#启动Tomcat
CMD ["/usr/local/tomcat/bin/catalina.sh", "run"]

##构建镜像

#Dockerfile 文件所在目录执行
语法:docker build -t {命名空间}/镜像名称:{版本}  .
docker build -t c/test:v1 .

[root@iZm5eh8nr0sr6z51jy72t4Z data]# docker build -t c/test:v1 .
Sending build context to Docker daemon  204.3MB
Step 1/18 : FROM centos:7
 ---> a8493f5f50ff
Step 2/18 : ADD ./soft/tomcat.tar.gz /usr/local/
 ---> Using cache
 ---> 02ca8824de66
Step 3/18 : ADD ./soft/jdk-7u80-linux-x64.tar.gz /usr/local/
 ---> Using cache
 ---> 55b2e278ee27
Step 4/18 : WORKDIR /usr/local/
......
......
Step 17/18 : WORKDIR /usr/local/tomcat/bin/
 ---> eda1f15ea591
Removing intermediate container 2890cf1fcd3a
Step 18/18 : CMD /usr/local/tomcat/bin/catalina.sh run
 ---> Running in 600a9c39db94
 ---> ef0863755c3a
Removing intermediate container 600a9c39db94
Successfully built ef0863755c3a
Successfully tagged c/test:v1

通过制作好的镜像启动 container

[root@iZm5eh8nr0sr6z51jy72t4Z data]# docker run -p 8080:8080 c/test:v1
May 08, 2017 6:46:18 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version:        Apache Tomcat/7.0.73
May 08, 2017 6:46:18 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built:          Nov 7 2016 21:27:23 UTC
May 08, 2017 6:46:18 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number:         7.0.73.0
May 08, 2017 6:46:18 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name:               Linux
May 08, 2017 6:46:18 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version:            3.10.0-514.6.2.el7.x86_64
May 08, 2017 6:46:18 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture:          amd64
May 08, 2017 6:46:18 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home:             /usr/local/jdk1.7.0_80/jre
May 08, 2017 6:46:18 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version:           1.7.0_80-b15
May 08, 2017 6:46:18 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor:            Oracle Corporation
May 08, 2017 6:46:18 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE:         /usr/local/tomcat
May 08, 2017 6:46:18 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME:         /usr/local/tomcat
May 08, 2017 6:46:18 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
May 08, 2017 6:46:18 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
May 08, 2017 6:46:18 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
May 08, 2017 6:46:18 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=/usr/local/tomcat/endorsed
May 08, 2017 6:46:18 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=/usr/local/tomcat
May 08, 2017 6:46:18 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=/usr/local/tomcat
May 08, 2017 6:46:18 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
May 08, 2017 6:46:18 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
May 08, 2017 6:46:18 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
May 08, 2017 6:46:18 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
May 08, 2017 6:46:18 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 698 ms
May 08, 2017 6:46:18 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
May 08, 2017 6:46:18 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.73
May 08, 2017 6:46:18 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/local/tomcat/webapps/manager
# 这里会卡一会需要优化
May 08, 2017 6:48:31 AM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [132,247] milliseconds.
May 08, 2017 6:48:31 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /usr/local/tomcat/webapps/manager has finished in 132,763 ms
May 08, 2017 6:48:31 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/local/tomcat/webapps/docs
May 08, 2017 6:48:31 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /usr/local/tomcat/webapps/docs has finished in 54 ms
May 08, 2017 6:48:31 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/local/tomcat/webapps/examples
May 08, 2017 6:48:31 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /usr/local/tomcat/webapps/examples has finished in 297 ms
May 08, 2017 6:48:31 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/local/tomcat/webapps/host-manager
May 08, 2017 6:48:31 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /usr/local/tomcat/webapps/host-manager has finished in 60 ms
May 08, 2017 6:48:31 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/local/tomcat/webapps/ROOT
May 08, 2017 6:48:31 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /usr/local/tomcat/webapps/ROOT has finished in 42 ms
May 08, 2017 6:48:31 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/local/tomcat/webapps/resources
May 08, 2017 6:48:31 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /usr/local/tomcat/webapps/resources has finished in 50 ms
May 08, 2017 6:48:31 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
May 08, 2017 6:48:31 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
May 08, 2017 6:48:31 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 133361 ms

tomcat过程中会卡一下,还需要优化 ##验证访问 输入图片说明

© 著作权归作者所有

caol
粉丝 5
博文 12
码字总数 4225
作品 0
北京
运维
私信 提问
制作docker镜像

基于alpine制作最小的tomcat镜像 #docker pull docker.io/frolvlad/alpine-oraclejdk8 #获取alpine镜像(包含jdk8),可以下载其他镜像 #tar xf apache-tomcat-8.5.24.tar.gz # mv apache-tomc......

小白的希望
2018/01/12
0
0
gradle build docker image

前言:其实gradle-docker插件干的事和我们手动制作镜像是一样的,只不过它封装了一些步骤而已、 eg:如果我们要将项目打包成镜像,首先我们要写Dockerfile,这是制作镜像的不可或缺的第一步,...

liuzhijian
2018/03/19
0
0
使用Dockerfile制作Docker镜像

使用Dockerfile制作Docker镜像 2017年06月03日 18:09:13 阅读数:2888 标签: docker-镜像Dockerfile 更多 个人分类: Docker 版权声明:本文为博主原创文章,未经博主允许不得转载。 https:...

linjin200
2018/08/23
4
0
Docker入门学习四之自己制作Docker镜像

一、制作自己的镜像 1.前提 Dockerfile : 用来告诉Docker,我要怎么制作我的镜像,我要制作镜像的每一个操作是什么 docker build : 该命令用来执行Dockerfile中所描述的每一件事情,最终将...

aibinxiao
2017/11/03
85
0
部署开发镜像化的笔记(逐步整理)

_让我们的开发环境镜像化搭建的记录(整理内容) 如果镜像需要定制化:建议直接拉取一个系统镜像然后自定义: 可以参照:基于docker官网镜像centos7配置Java运行环境 注意自定义的脚本中exp...

月夜筱风
2016/12/13
45
0

没有更多内容

加载失败,请刷新页面

加载更多

Spring使用ThreadPoolTaskExecutor自定义线程池及实现异步调用

多线程一直是工作或面试过程中的高频知识点,今天给大家分享一下使用 ThreadPoolTaskExecutor 来自定义线程池和实现异步调用多线程。 一、ThreadPoolTaskExecutor 本文采用 Executors 的工厂...

CREATE_17
今天
5
0
CSS盒子模型

CSS盒子模型 组成: content --> padding --> border --> margin 像现实生活中的快递: 物品 --> 填充物 --> 包装盒 --> 盒子与盒子之间的间距 content :width、height组成的 内容区域 padd......

studywin
今天
7
0
修复Win10下开始菜单、设置等系统软件无法打开的问题

因为各种各样的原因导致系统文件丢失、损坏、被修改,而造成win10的开始菜单、设置等系统软件无法打开的情况,可以尝试如下方法解决 此方法只在部分情况下有效,但值得一试 用Windows键+R打开...

locbytes
昨天
8
0
jquery 添加和删除节点

本文转载于:专业的前端网站➺jquery 添加和删除节点 // 增加一个三和一节点function addPanel() { // var newPanel = $('.my-panel').clone(true) var newPanel = $(".triple-panel-con......

前端老手
昨天
8
0
一、Django基础

一、web框架分类和wsgiref模块使用介绍 web框架的本质 socket服务端 与 浏览器的通信 socket服务端功能划分: 负责与浏览器收发消息(socket通信) --> wsgiref/uWsgi/gunicorn... 根据用户访问...

ZeroBit
昨天
10
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部