Docker容器

docker版本      : 1.7.1

系统    版本     :CentOS release 6.8

tomcat版本    :apache-tomcat-7.0.57

memcache版本:yum安装

Docker 容器在运行里有些步骤出错会产生<none>之类的无效镜像,产生之后直接运行脚本

删除

[root@1xx tom]#cat kong.sh

#!/bin/bash

#

for I in `docker p_w_picpaths | grep"<none>" | awk -F" " '{print $3}'`;do

echo"none key name $I"

dockerstop $I

docker  rmi -f $I

echo$keys

done

docker p_w_picpaths

Tomcat 配置

[root@1xx tom]#cat Dockerfile

FROM centos                                                   #基础镜像来自于centos

MAINTAINER xiong <812374156@qq.com>  #作者信息

#安装ifconfig 类型工具

RUN yum -y install net-tools

#ADD复制本地文件并自动解压至目录下

ADD apache-tomcat-7.0.57.tar.gz/usr/local/

# 运行软链接命令

RUN ln -sv /usr/local/apache-tomcat-7.0.57/usr/local/tomcat

# 定义tomcat环境变量值

ENV CATALINA_HOME /usr/local/tomcat

ENV PATH $PATH:$CATALINA_HOME/bin

#复制jdk文件到root目录并使用rpm命令安装

COPY jdk-7u79-linux-x64.rpm /root/

RUN rpm -ivh  /root/jdk-7u79-linux-x64.rpm

#定义java环境变量

ENV JAVA_HOME=/usr/java/latest

ENV PATH $PATH:$JAVA_HOME/bin

# 当机器运行里自动启动,此处可省略

RUN echo"/usr/local/tomcat/catalina.sh start" >> /etc/rc.d/rc.local

# 产先配置好server.xml文件然后直接复制到conf文件目录下

COPY server.xml /usr/local/tomcat/conf/

# 复制msm文件至lib文件下

COPY mem/* /usr/local/tomcat/lib/

# 运行启动catalina.sh脚本使用run 脚本在运行之后启动并打印debug信息在使用ctrl+p ctrl+q 运行容器,否则脚本运行后之后脚本会退出

CMD["catalina.sh","run"]

Msm下载

memcached session manager

https://github.com/magro/memcached-session-manager/wiki/SetupAndConfiguration

memcached-session-manager-tc6-${version}.jar for tomcat6,

memcached-session-manager-tc7-${version}.jar for tomcat7

(attention: tomcat 7.0.23+) or memcached-session-manager-tc8-${version}.jar for tomcat8.

下载需要注意版本信息      并且需要注意的是版本号需要对应一致否则有可能报错

javolution-5.4.3.1.jar

memcached-session-manager-tc7-2.1.1.jar

spymemcached-2.11.1.jar

memcached-session-manager-2.1.1.jar

msm-javolution-serializer-2.1.1.jar                        #也可以选择其它

tomcat删除脚本

[root@1xxtom]#cat del.sh

#!/bin/bash

#

docker rm -f tom{1..9}

docker rm -f mem{1..9}

docker rmi xiong

docker build -t xiong .

docker p_w_picpaths

Memcached 配置

[root@1xx memcached]# cat Dockerfile

FROMcentos                                                          #基础镜像来自于centos

MAINTAINER xiong812374156@qq.com        #作者信息

RUN yum -yinstall memcached net-tools        #安装mem以及ifconfig 类型工具

#运行memcached命令,别使用daemon 脚本在运行完之后容器会自动退出

CMD["/usr/bin/memcached","-p","11211","-m","64","-c","1024","-u","root"]

Memcached删除脚本

[root@1xxmemcached]# cat del.sh

#!/bin/bash

#

#

docker rm -f mem1

docker rmi mem

docker build -t mem .

配置完基础镜像运行容器,为方便我这里也定义了脚本

[root@1xx tom]#cat docktest.sh

#!/bin/bash

#

# docker 运行容器名称tom2 端口本地92 容器8080 数据卷本地xx/xx/tom2/ 容器/web/apps 基础镜像

docker run -it--name tom2 -p 92:8080 -v /root/tom/tom2:/web/apps/ xiong

docker run -it--name tom3 -p 93:8080 -v /root/tom/tom3:/web/apps/ xiong

#docker 运行容器名称m2m1 端口本地201 远端11211 基础镜像

docker run -it--name mem1 -p 201:11211 mem

docker run -it--name mem2 -p 202:11211 mem

docker ps

# 测试容器memcached是否运行成功 本地运行telnet

容器tom2号 session信息

JSESSIONID=A4B7390062C98E719D1CBF5C198F835D-n2

JSESSIONID=A4B7390062C98E719D1CBF5C198F835D-n2

验证

Session信息一致说明成功

Service.xml文件内容

[root@1xx tom]# cat server.xml

<?xmlversion='1.0' encoding='utf-8'?>

<!--

Licensed to the Apache Software Foundation(ASF) under one or more

contributor license agreements.  See the NOTICE file distributed with

thiswork for additional information regarding copyright ownership.

The ASF licenses this file to You under theApache License, Version 2.0

(the "License"); you may not usethis file except in compliance with

the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreedto in writing, software

distributed under the License is distributedon an "AS IS" BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,either express or implied.

See the License for the specific languagegoverning permissions and

limitations under the License.

-->

<!--Note:  A "Server" is not itselfa "Container", so you may not

define subcomponents such as"Valves" at this level.

Documentation at /docs/config/server.html

-->

<Serverport="8005" shutdown="SHUTDOWN">

<ListenerclassName="org.apache.catalina.startup.VersionLoggerListener" />

<!-- Security listener. Documentation at/docs/config/listeners.html

<ListenerclassName="org.apache.catalina.security.SecurityListener" />

-->

<!--APR library loader. Documentation at/docs/apr.html -->

<ListenerclassName="org.apache.catalina.core.AprLifecycleListener"SSLEngine="on" />

<!--Initialize Jasper prior to webapps areloaded. Documentation at /docs/jasper-howto.html -->

<ListenerclassName="org.apache.catalina.core.JasperListener" />

<!-- Prevent memory leaks due to use ofparticular java/javax APIs-->

<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>

<ListenerclassName="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>

<ListenerclassName="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>

<!-- Global JNDI resources

Documentation at/docs/jndi-resources-howto.html

-->

<GlobalNamingResources>

<!-- Editable user database that canalso be used by

UserDatabaseRealm to authenticateusers

-->

<Resource name="UserDatabase"auth="Container"

type="org.apache.catalina.UserDatabase"

description="User databasethat can be updated and saved"

factory="org.apache.catalina.users.MemoryUserDatabaseFactory"

pathname="conf/tomcat-users.xml"/>

</GlobalNamingResources>

<!-- A "Service" is a collectionof one or more "Connectors" that share

a single "Container"Note:  A "Service" is notitself a "Container",

so you may not define subcomponents suchas "Valves" at this level.

Documentation at/docs/config/service.html

-->

<Service name="Catalina">

<!--The connectors can use a sharedexecutor, you can define one or more named thread pools-->

<!--

<Executorname="tomcatThreadPool" namePrefix="catalina-exec-"

maxThreads="150"minSpareThreads="4"/>

-->

<!-- A "Connector" representsan endpoint by which requests are received

and responses are returned.Documentation at :

Java HTTP Connector: /docs/config/http.html(blocking & non-blocking)

Java AJP  Connector: /docs/config/ajp.html

APR (HTTP/AJP) Connector:/docs/apr.html

Define a non-SSL HTTP/1.1 Connector onport 8080

-->

<Connector port="8080"protocol="HTTP/1.1"

connectionTimeout="20000"

redirectPort="8443"/>

<!-- A "Connector" using theshared thread pool-->

<!--

<Connectorexecutor="tomcatThreadPool"

port="8080"protocol="HTTP/1.1"

connectionTimeout="20000"

redirectPort="8443"/>

-->

<!-- Define a SSL HTTP/1.1 Connector onport 8443

This connector uses the BIOimplementation that requires the JSSE

style configuration. When using theAPR/native implementation, the

OpenSSL style configuration isrequired as described in the APR/native

documentation -->

<!--

<Connector port="8443"protocol="org.apache.coyote.http11.Http11Protocol"

maxThreads="150"SSLEnabled="true" scheme="https" secure="true"

clientAuth="false"sslProtocol="TLS" />

-->

<!-- Define an AJP 1.3 Connector on port8009 -->

<Connector port="8009"protocol="AJP/1.3" redirectPort="8443" />

<!-- An Engine represents the entrypoint (within Catalina) that processes

every request.  The Engine implementation for Tomcat standalone

analyzes the HTTP headers includedwith the request, and passes them

on to the appropriate Host (virtualhost).

Documentation at/docs/config/engine.html -->

<!-- You should set jvmRoute to supportload-balancing via AJP ie :

<Engine name="Catalina"defaultHost="localhost" jvmRoute="jvm1">

-->

<Engine name="Catalina" defaultHost="localhost">

<!--For clustering, please take a lookat documentation at:

/docs/cluster-howto.html  (simple how to)

/docs/config/cluster.html (referencedocumentation) -->

<!--

<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>

-->

<!-- Use the LockOutRealm to preventattempts to guess user passwords

via a brute-force attack -->

<RealmclassName="org.apache.catalina.realm.LockOutRealm">

<!-- This Realm uses theUserDatabase configured in the global JNDI

resources under the key"UserDatabase".  Any edits

that are performed against thisUserDatabase are immediately

available for use by theRealm.  -->

<Realm className="org.apache.catalina.realm.UserDatabaseRealm"

resourceName="UserDatabase"/>

</Realm>

<Host name="localhost"appBase="/web/apps" unpackWARs="true"autoDeploy="false">

<Context path=""docBase="/web/apps/" reloadable="true" >

<ManagerclassName="de.javakaffee.web.msm.MemcachedBackupSessionManager"

memcachedNodes="n1:192.168.8.101:201,n2:192.168.8.101:202"

failoverNodes="n1"

storageKeyPrefix="context"

requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"

transcoderFactoryClass="de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"

/>

</Context>

<ValveclassName="org.apache.catalina.valves.AccessLogValve"directory="/web/logs"

prefix="app_access_log"suffix=".txt"

pattern="%h %l %u %t&quot;%r&quot; %s %b" />

</Host>

</Engine>

</Service>

</Server>

Tomcat数据卷中 tomcat 目录 index.jsp

[root@1xx tom]# cat tom2/index.jsp

<%@ page language="java" %>

<%@ page import="java.util.*"%>

<html>

<head>

<title>tom2</title>

</head>

<body>

<% out.println("Hello,tom2."); %>

</body>

</html>

转载于:https://blog.51cto.com/xiong51/1898356

docker实现tomcat+jdk+msm相关推荐

  1. 在docker中搭建apache Tomcat+JDK环境

    本人电脑环境:安装好docker的open SUSE操作系统 最终的docker镜像:ubuntu+tomcat+jdk 运行ubuntu镜像 sudo docker run -it -v /home ...

  2. docker 部署 tomcat 服务

    查找tomcat 镜像 docker search tomcat [root@izr86o15kikb3az tomcat]# docker search tomcat NAME DESCRIPTIO ...

  3. Docker创建 tomcat/weblogic 集群

    安装 tomcat 镜像 准备好需要的 jdk.tomcat 等软件放到 home 目录下面,启动一个容器 docker run -t -i -v /home:/opt/data --name mk_ ...

  4. docker 发布tomcat项目_Docker部署java项目[tomcat环境]

    公司的一个java项目,然后这是组长给的一个任务,部署到docker中. 部署更不用说啦,肯定要写Dockerfile,不多想,先下载我需要的环境包. 1. JDK [JDK下载地址](Java SE ...

  5. Docker(四):使用Docker部署tomcat、mysql、nginx静态服务器

    使用Dokcer可以很好的对镜像进行管理,创建和使用容器.这篇博客将简单介绍一下如何使用Docker来安装Tomcat.Mysql和Nginx文件服务器.相关阅读: Docker(一):Docker的 ...

  6. docker生成tomcat镜像

    应用场景 有时候docker公共镜像库中下载下来的镜像,可能不是自己想要的,没办法,自己也可以制作一个自己想要的镜像,然后发布到公共资源镜像中,也可以保存到私有仓库中,以防后期自己也需要使用. 操作步 ...

  7. 在preferences窗口找不到要运行的tomcat_基于docker安装tomcat例子

    1.访问https://hub.docker.com/网站 2.找到tomcat 3.找到自己要下载的镜像的版本,我这里下载最新的 4.下载最新的版本 docker pull tomcat 5.创建t ...

  8. docker启动tomcat容器并添置项目首页

    拉取镜像 docker search tomcat查询tomcat镜像,也可以根据自己需求,去docker仓库查找需要的版本,再docker pull 下来. 可选的版本有很多,做测试,就随便选择了一 ...

  9. docker制作tomcat镜像并部署war包

    模拟面试小白: 需求:有一台没有网络的服务器,使用docker部署war包,没有tomcat镜像,限时30分钟. 小白:没网部署war包干啥,是不是工作不饱和让你们太闲了. 我:傻瓜,怪我没表达清楚, ...

最新文章

  1. 网页热点区域神器工具大曝光
  2. 【数据结构与算法】之深入解析“二叉树的层序遍历”的求解思路与算法示例
  3. 结对开发——求最大值
  4. Error:collect2:ld returned 1 exit status的其他原因
  5. 迷宫(信息学奥赛一本通-T1215)
  6. java testwhileidle,springboot使用druid时报错:testWhileIdle is true, validationQuery not set
  7. Winform中自定义xml配置文件后对节点进行读取与写入(XmlDocument)
  8. 工作流集成表单的过程
  9. java 解析dataset_C# DataSet用法的详细解析|C#教程
  10. python竖线_python画横线竖线作为分界线
  11. 解决 CAP_IMAGES: can‘t find starting number (in the name of file)
  12. MySQL数据库:表结构优化
  13. excel表格打印每页都有表头_Excel打印时如何实现每一页纸上都有表头?
  14. 2023最新SSM计算机毕业设计选题大全(附源码+LW)之java古诗词知识学习系统q5697
  15. kettle 9.x 版本连接资源库,资源库灰色
  16. 线程、进程、多线程、多进程 和 多任务
  17. typora + smss / github / 又拍云 / 七牛云 图床
  18. 在Windows10中对于文件做MD5校验
  19. Skyline WEB端开发3——添加一个弹框
  20. Qt - WPS文本编辑器(WPS字体格式)

热门文章

  1. python和c语言有什么关系-Python与c语言的区别
  2. work-notes(8):如何制作卡片凹陷?如何制作梯形?如何制作有凹陷的盒子?如何制作透明凹陷?
  3. 人到中年意如何?创业艰难百战多
  4. 06_frpc启动流程
  5. 谷歌-BTS-APVI-项目官网
  6. RxSwift学习--特征序列之Driver
  7. python find 正则表达式_python正则表达式
  8. oracle数据库优化-IO性能分析优化
  9. php微信小程序毕业设计 php充电桩共享小程序毕业设计毕设作品参考
  10. 企业态势感知系统构建开发实战