docker下安装tomcat

一,查看tomcat镜像

[root@icompany ~]# docker search tomcat
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/tomcat Apache Tomcat is an open source implementa... [OK]
docker.io docker.io/dordoka/tomcat Ubuntu 14.04, Oracle JDK and Tomcat ba... [OK]
docker.io docker.io/tomee Apache TomEE is an all-Apache Java EE cert... [OK]
docker.io docker.io/davidcaste/alpine-tomcat Apache Tomcat / using Oracle Java / wi... [OK]
docker.io docker.io/consol/tomcat-7.0 Tomcat 7.0., , "admin/admin" [OK]
docker.io docker.io/cloudesire/tomcat Tomcat server, // [OK]
docker.io docker.io/bitnami/tomcat Bitnami Tomcat Docker Image [OK]
docker.io docker.io/jeanblanchard/tomcat Minimal Docker image with Apache Tomcat
docker.io docker.io/meirwa/spring-boot-tomcat-mysql-app a sample spring-boot app using tomcat and ... [OK]
docker.io docker.io/tutum/tomcat Base docker image to run a Tomcat applicat...
docker.io docker.io/aallam/tomcat-mysql Debian, Oracle JDK, Tomcat & MySQL [OK]
docker.io docker.io/rightctrl/tomcat CentOS , Oracle Java, tomcat application s... [OK]
docker.io docker.io/99taxis/tomcat7 Tomcat7 [OK]
docker.io docker.io/amd64/tomcat Apache Tomcat is an open source implementa...
docker.io docker.io/camptocamp/tomcat-logback Docker image for tomcat with logback integ... [OK]
docker.io docker.io/maluuba/tomcat7-java8 Tomcat7 with java8.
docker.io docker.io/primetoninc/tomcat Apache tomcat 8.5, 8.0, 7.0 [OK]
docker.io docker.io/awscory/tomcat tomcat
docker.io docker.io/buravelli9/tomcat-az-standards Tomcat image-AZ
docker.io docker.io/fabric8/tomcat- Fabric8 Tomcat Image [OK]
docker.io docker.io/hegand/tomcat docker-tomcat [OK]
docker.io docker.io/oobsri/tomcat8 Testing CI Jobs with different names.
docker.io docker.io/picoded/tomcat7 tomcat7 with jre8 and MANAGER_USER / MANAG... [OK]
docker.io docker.io/s390x/tomcat Apache Tomcat is an open source implementa...
docker.io docker.io/swisstopo/service-print-tomcat backend tomcat for service-print "the true... 0

二,下载tomcat镜像

[root@icompany ~]# docker pull tomcat
Using default tag: latest
Trying to pull repository docker.io/library/tomcat ...
latest: Pulling from docker.io/library/tomcat
c73ab1c6897b: Pull complete
1ab373b3deae: Pull complete
b542772b4177: Pull complete
0bcc3741ab14: Pull complete
421d624d778d: Pull complete
26ad58237506: Pull complete
8dbabc90b2b8: Pull complete
982930be204d: Pull complete
80869be51738: Pull complete
ebc6831d2466: Pull complete
e1d0586dfcce: Pull complete
f84378b2ff18: Pull complete
Digest: sha256:7c92449dee0052dfd5764765c9f173164d7d9675373d4d51d59515d98cbb2661
Status: Downloaded newer image for docker.io/tomcat:latest

三,启动tomcat容器

[root@icompany root]# docker run --name tomcat80 -p : -v $PWD/docker/tomcat80/test:/usr/local/tomcat/webapps/test -d tomcat
37b7248898294b37d34f595cf368c126659aba8f70665b1acc18e515b326bd13

四,进入tomcat命令行

[root@icompany ~]# docker exec -it tomcat80 bash
root@37b724889829:/usr/local/tomcat#

五,生成Dockerfile

#!/bin/bash
FROM tomcat:8.0
MAINTAINER lichao "lcjiang@xxx.com"
RUN rm -rf /usr/local/tomcat/webapps/ROOT/
RUN rm -rf /usr/local/tomcat/webapps/ROOT.war RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime #解决时区不一致问题 ADD /root/docker/tomcat80/src/netsharp/netsharp-web/build/libs/netsharp-web-2.6.-SNAPSHOT.war /data/home/work/tomcat/webapps/ROOT.war

六,git相关命令

git config --global user.name 'xx'
git config --global user.email 'fbxu@xx.com' git init
git clone git@gitlab.xx.com:netsharp/netsharp.git

其他

1.httpddocker下安装

sudo docker pull httpd
sudo docker run -it -d -p : --name httpd81 -v /opt/httpd/www/:/usr/local/apache2/htdocs/
sudo docker ps
sudo docker exec -it 58141445438c /bin/bash
上一篇:Linux下Docker容器安装与使用


下一篇:Docker容器部署tomcat出现中文乱码