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...   1757      [OK]       
docker.io   docker.io/dordoka/tomcat                        Ubuntu 14.04, Oracle JDK 8 and Tomcat 8 ba...   48                   [OK]
docker.io   docker.io/tomee                                 Apache TomEE is an all-Apache Java EE cert...   47        [OK]       
docker.io   docker.io/davidcaste/alpine-tomcat              Apache Tomcat 7/8 using Oracle Java 7/8 wi...   24                   [OK]
docker.io   docker.io/consol/tomcat-7.0                     Tomcat 7.0.57, 8080, "admin/admin"              16                   [OK]
docker.io   docker.io/cloudesire/tomcat                     Tomcat server, 6/7/8                            15                   [OK]
docker.io   docker.io/bitnami/tomcat                        Bitnami Tomcat Docker Image                     10                   [OK]
docker.io   docker.io/jeanblanchard/tomcat                  Minimal Docker image with Apache Tomcat         8                    
docker.io   docker.io/meirwa/spring-boot-tomcat-mysql-app   a sample spring-boot app using tomcat and ...   8                    [OK]
docker.io   docker.io/tutum/tomcat                          Base docker image to run a Tomcat applicat...   8                    
docker.io   docker.io/aallam/tomcat-mysql                   Debian, Oracle JDK, Tomcat & MySQL              6                    [OK]
docker.io   docker.io/rightctrl/tomcat                      CentOS , Oracle Java, tomcat application s...   3                    [OK]
docker.io   docker.io/99taxis/tomcat7                       Tomcat7                                         1                    [OK]
docker.io   docker.io/amd64/tomcat                          Apache Tomcat is an open source implementa...   1                    
docker.io   docker.io/camptocamp/tomcat-logback             Docker image for tomcat with logback integ...   1                    [OK]
docker.io   docker.io/maluuba/tomcat7-java8                 Tomcat7 with java8.                             1                    
docker.io   docker.io/primetoninc/tomcat                    Apache tomcat 8.5, 8.0, 7.0                     1                    [OK]
docker.io   docker.io/awscory/tomcat                        tomcat                                          0                    
docker.io   docker.io/buravelli9/tomcat-az-standards        Tomcat image-AZ                                 0                    
docker.io   docker.io/fabric8/tomcat-8                      Fabric8 Tomcat 8 Image                          0                    [OK]
docker.io   docker.io/hegand/tomcat                         docker-tomcat                                   0                    [OK]
docker.io   docker.io/oobsri/tomcat8                        Testing CI Jobs with different names.           0                    
docker.io   docker.io/picoded/tomcat7                       tomcat7 with jre8 and MANAGER_USER / MANAG...   0                    [OK]
docker.io   docker.io/s390x/tomcat                          Apache Tomcat is an open source implementa...   0                    
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 80:8080 -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.4-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 81:80 --name httpd81 -v /opt/httpd/www/:/usr/local/apache2/htdocs/
sudo docker ps
sudo docker exec -it 58141445438c /bin/bash

 

posted on 2018-03-31 17:35  Netsharp  阅读(297)  评论(0编辑  收藏  举报

导航