docker linux centos install tomcat

37.4 Create docker centos-ssh-root-java-tomcat 

 

37.4.0 Prerequisite has a centos-ssh-root-java

 

 

37.4.1 Editing the dockerfile

 

############################################
# version:apache-tomcat-7.0.75
# desc : 7.0.75 installed by the current version
############################################

# The settings are inherited from the tools image we created
FROM curiousby/centos-ssh-root-java:original

# Below is some basic information about the creator
MAINTAINER baoyou [email protected]

# Copy the apache-tomcat-7.0.75.tar.gz file to the mirror
ADD apache-tomcat-7.0.75.tar.gz /usr/local/

# set soft connection
RUN ln -s /usr/local/apache-tomcat-7.0.75 /usr/local/tomcat


# Set the environment variables of tomcat, if the reader has other environment variables to set
ENV CATALINA_HOME /usr/local/apache-tomcat-7.0.75


# The container needs to open Tomcat port 8080
EXPOSE 8080

COPY autorun.sh /usr/local/tomcat/bin/autorun.sh

RUN chmod u+x /usr/local/tomcat/bin/autorun.sh

# auto start
CMD ["/usr/local/tomcat/bin/autorun.sh"]

 

 

 

37.4.2 Editing the Autostart Script

 

#!/bin/bash
source ~/.bashrc

sh /usr/local/tomcat/bin/catalina.sh run

 

 

37.4.3 Execute commands

 

cd centos-ssh-root-java
cp ../apache-tomcat-7.0.75.tar.gz .
vim  Dockerfile
tar -xf apache-tomcat-7.0.75.tar.gz
vim apache-tomcat-7.0.75.tar.gz / bin / catalina.sh
add code
	export JAVA_HOME=/usr/local/jdk1.7.0_79  
	export JRE_HOME=/usr/local/jdk1.7.0_79/jre  
	export CATALINA_HOME=/usr/local/apache-tomcat-7.0.75  
	export CATALINA_BASE=/usr/local/apache-tomcat-7.0.75  
	export CATALINA_TMPDIR=/usr/local/apache-tomcat-7.0.75/temp

cp apache-tomcat-7.0.75.tar.gz / bin / catalina.sh.

vim  autorun.sh

#!/bin/bash
source ~/.bashrc

sh /usr/local/tomcat/bin/catalina.sh run

docker build -t "curiousby/centos-ssh-root-java-tomcat:original" .


docker run -d -p 8080:8080 curiousby/centos-ssh-root-java-tomcat:original  -v /docker/tomcat1/logs/:/usr/local/tomcat/logs
docker run -d -p 8081:8080 curiousby/centos-ssh-root-java-tomcat:original -v /docker/tomcat1/logs/:/usr/local/tomcat/logs
docker run -d -p 8082:8080 curiousby/centos-ssh-root-java-tomcat:original -v /docker/tomcat1/logs/:/usr/local/tomcat/logs

 

 

37.4.4 Running the build log



 

#build run log
[root@localhost centos-ssh-root-java-tomcat]# docker build -t curiousby/centos-ssh-root-java-tomcat:original .
Sending build context to Docker daemon  8.967MB
Step 1/9 : FROM curiousby/centos-ssh-root-java:original
 ---> b927a708d880
Step 2/9 : MAINTAINER baoyou [email protected]
 ---> Running in c714e382a89f
 ---> 8843e826df75
Removing intermediate container c714e382a89f
Step 3/9 : ADD apache-tomcat-7.0.75.tar.gz /usr/local/
 ---> d658ff1a2ba5
Removing intermediate container efb719168d48
Step 4/9 : RUN ln -s /usr/local/apache-tomcat-7.0.75 /usr/local/tomcat
 ---> Running in 799eb96d5d2a
 ---> 96623ac69cbd
Removing intermediate container 799eb96d5d2a
Step 5/9 : ENV CATALINA_HOME /usr/local/apache-tomcat-7.0.75
 ---> Running in c59375c73a1d
 ---> b707eae87825
Removing intermediate container c59375c73a1d
Step 6/9 : EXPOSE 8080
 ---> Running in 482ebe032044
 ---> e52bb95bb46e
Removing intermediate container 482ebe032044
Step 7/9 : COPY autorun.sh /usr/local/tomcat/bin/autorun.sh
 ---> 3cfd1c86bccf
Removing intermediate container c1aa90cb1121
Step 8/9 : RUN chmod u+x /usr/local/tomcat/bin/autorun.sh
 ---> Running in 4b3ccdeb4f53
 ---> 54988bebb05c
Removing intermediate container 4b3ccdeb4f53
Step 9/9 : CMD /usr/local/tomcat/bin/autorun.sh
 ---> Running in c1235f2f90e2
 ---> 7dd208c74262
Removing intermediate container c1235f2f90e2
Successfully built 7dd208c74262
Successfully tagged curiousby/centos-ssh-root-java-tomcat:original
[root@localhost centos-ssh-root-java-tomcat]#

 

37.4.5 Running run results



 

docker run -d -p 8080:8080 curiousby/centos-ssh-root-java-tomcat:original
docker run -d -p 8081:8080 curiousby/centos-ssh-root-java-tomcat:original
docker run -d -p 8082:8080 curiousby/centos-ssh-root-java-tomcat:original

 

docker run -d -p 8080:8080 curiousby/centos-ssh-root-java-tomcat:original  -v /docker/tomcat1/logs/:/usr/local/tomcat/logs
docker run -d -p 8081:8080 curiousby/centos-ssh-root-java-tomcat:original -v /docker/tomcat1/logs/:/usr/local/tomcat/logs
docker run -d -p 8082:8080 curiousby/centos-ssh-root-java-tomcat:original -v /docker/tomcat1/logs/:/usr/local/tomcat/logs

  

37.4.6 Running the run web page



 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Donate to developers 

Driven by interest, I write 免费something with joy and sweat. I hope you like my work and can support it at the same time. Of course, if you have money to support a money field (support Alipay, WeChat, and the buckle group), if you have no money to support a personal field, thank you.

 

Personal homepage : http://knight-black-bob.iteye.com/



 
 
 Thank you for your sponsorship, I will do better!

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326803873&siteId=291194637