本文共 8178 字,大约阅读时间需要 27 分钟。
docker search
可以查到最流行的(和官方的)Docker Tomcat容器: $ sudo docker search tomcat[sudo] password for craig: NAME DESCRIPTION STARS OFFICIAL AUTOMATEDtomcat Apache Tomcat is an open source implementa... 103 [OK] tutum/tomcat Tomcat image - listens in port 8080. For t... 38 [OK]consol/tomcat-7.0 Tomcat 7.0.57, 8080, "admin/admin" 12 [OK]consol/tomcat-8.0 Tomcat 8.0.15, 8080, "admin/admin" 9 [OK]consol/tomcat-6.0 Tomcat 6.0.43, 8080, "admin/admin" 6 [OK]consol/tomcat-4.1 Tomcat 4.1.40, 8080, "admin/admin" 4 [OK]consol/tomcat-5.0 Tomcat 5.0.30, 8080, "admin/admin" 4 [OK]consol/tomcat-5.5 Tomcat 5.5.36, 8080, "admin/admin" 4 [OK]consol/tomcat-3.3 Tomcat 3.3.2, 8080, "admin/admin" 4 [OK]readytalk/tomcat-native Debian backed Tomcat + Tomcat Native Library 3 [OK]malderhout/tomcat Tomcat7 with OpenJDK7 on CentOS7 3 [OK]dordoka/tomcat Ubuntu 14.04, Oracle JDK 8 and Tomcat 8 ba... 3 [OK]meirwa/spring-boot-tomcat-mysql-app a sample spring-boot app using tomcat and ... 2 [OK]h2000/docker-tomcat-youtrack Dockerfile for youtrack to run under tomcat. 1 [OK]nicescale/tomcat Tomcat service for NiceScale. http://nices... 1 [OK]dmean/liferay-tomcat Debian + Liferay CE Tomcat 1 [OK]atomi/tomcat 0 [OK]mminke/apache-tomcat A Docker image which contains the Apache T... 0 [OK]ericogr/tomcat Tomcat 8.0.21, 8080, "docker/docker" 0 [OK]holmes/tomcat 0 [OK]paulkling/tomcat 0 [OK]dynamind/tomcat 0 [OK]fabric8/tomcat-8.0 runs Apache Tomcat 8.0 with jolokia enable... 0 [OK]learninglayers/tomcat 0 [OK]dmglab/tomcat CentOS 7 based tomcat installation 0 [OK]
tomcat:7
。 FROM tomcat:7-jre7MAINTAINER "Craig Trim"
$ sudo docker build -t craig/tomcat .
tomcat:7-jre7 ns/tomcatmysql:5.6.23 ns/mysqlfgrehm/eclipse:v4.4.1 ns/eclipse
ns
代表命名空间,每个项目成员都能理解。启动容器只需要记住项目代码名(命名空间)和应用名称即可。 $ sudo docker run -p 8080:8080 craig/tomcat
$ sudo docker run -p 8081:8080 craig/tomcat
settings.xml
,更新 tomcat-user.xml
文件。如下所示: TomcatServer craig password
FROM tomcat:7-jre7MAINTAINER "Craig Trim"ADD settings.xml /usr/local/tomcat/conf/ADD tomcat-users.xml /usr/local/tomcat/conf/
$ sudo docker build -t craig/tomcat .Sending build context to Docker daemon 5.632 kBSending build context to Docker daemon Step 0 : FROM tomcat:7-jre7---> 77eb038c09d1Step 1 : MAINTAINER "Craig Trim"---> Using cache---> cadc51a3054cStep 2 : ADD settings.xml /usr/local/tomcat/conf/---> Using cache---> 5009ba884f1fStep 3 : ADD tomcat-users.xml /usr/local/tomcat/conf/---> Using cache---> 33917c541bb5Successfully built 33917c541bb5
$ sudo docker history craig/tomcatIMAGE CREATED CREATED BY SIZE33917c541bb5 4 hours ago /bin/sh -c #(nop) ADD file:c1d08c42d5808537b4 1.761 kB5009ba884f1f 4 hours ago /bin/sh -c #(nop) ADD file:5dd8f0f6d0cd64de3c 212 Bcadc51a3054c 4 hours ago /bin/sh -c #(nop) MAINTAINER "Craig Trim
$ tree.+-- pom.xml+-- src¦ +-- main¦ ¦ +-- java¦ ¦ +-- com¦ ¦ +-- trimc¦ ¦ +-- blogger
org.apache.tomcat.maven tomcat7-maven-plugin 2.2 http://localhost:8080/manager/text TomcatServer /sample craig password
$ mvn tomcat7:deploy[INFO] Scanning for projects...[INFO] [INFO] ------------------------------------------------------------------------[INFO] Building Test Runtime 1.0.0[INFO] ------------------------------------------------------------------------[INFO] *** SNIP ***[INFO] --- tomcat7-maven-plugin:2.2:deploy (default-cli) @ sandbox-web2 ---[INFO] Deploying war to http://localhost:8080/test Uploading: http://localhost:8080/manager/text/deploy?path=%2FtestUploaded: http://localhost:8080/manager/text/deploy?path=%2Ftest (1352 KB at 18512.6 KB/sec)[INFO] tomcatManager status code:200, ReasonPhrase:OK[INFO] OK - Deployed application at context path /test[INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time: 3.495 s[INFO] Finished at: 2015-03-31T19:08:12-07:00[INFO] Final Memory: 15M/506M[INFO] ------------------------------------------------------------------------
Apr 01, 2015 2:08:12 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiateINFO: Initiating Jersey application, version 'Jersey: 1.9 09/02/2011 11:17 AM' Apr 01, 2015 2:08:12 AM org.apache.catalina.startup.HostConfig deployWARINFO: Deployment of web application archive /usr/local/tomcat/webapps/test.war has finished in 826 ms
转载地址:http://gokia.baihongyu.com/