In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to customize the tomcat image of Dockerfile in docker, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
1. Create a directory
[root@t-docker chenzx] # mkdir tomcat9
2. Touch c.txt in the above directory in order to demonstrate the function of the copy instruction
[root@t-docker tomcat9] # touch c.txt
3. Copy the compressed package installed by jdk and tomcat into the previous directory
[root@t-docker tomcat9] # lsatlassian-confluence-6.11.0.tar.gz c.txt jdk1.8.0_65.tar.gz
4. Create a new Dockerfile file
[root@t-docker tomcat9] # cat Dockerfile FROM centosMAINTAINER chenzx# copies the c.txt of the current context of the host to the container / opt path COPY c.txt / opt/container.txt# uses the ADD instruction to add java and tomcat packages to the container, and automatically decompresses ADD atlassian-confluence-6.11.0.tar.gz / optADD jdk1.8.0_65.tar.gz / opt# installs the vim editor RUN yum-y install vim# to set the WORKDIR path for work access Login destination ENV MYPATH / optWORKDIR $MYPATH# configure java and tomcat environment variable ENV JAVA_HOME/ opt/jdk1.8.0_65ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarENV CATALINA_HOME/ opt/atlassian-confluence-6.11.0ENV CATALINA_BASE / opt/atlassian-confluence-6.11.0ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/bin# container runtime listening port EXPOSE 808 starts Run tomcat#ENTRYPOINT ["/ opt/atlassian-confluence-6.11.0/bin/startup.sh"] # CMD ["/ opt/atlassian-confluence-6.11.0/bin/catalina.sh" when "run"] CMD / opt/atlassian-confluence-6.11.0/bin/startup.sh & & tail-F / opt/atlassian-confluence-6.11.0/logs/catalina.out
5. Construction
[root@t-docker tomcat9] # docker build-t tomcat9 .Sending build context to Docker daemon 719MBStep 1 COPY c.txt 15: FROM centos-- > 5182e96772bfStep 2 COPY c.txt 15: MAINTAINER chenzx-- > Running in d04f35bb304dRemoving intermediate container d04f35bb304d-- > b1535d029856Step 3 opt/container.txt 15: COPY c.txt / opt/container.txt-- > ef3569b7b95dStep 4 opt/container.txt 15: ADD atlassian-confluence-6.11.0.tar.gz / opt-- > 0aed885f1740Step 5 COPY c.txt 15: ADD jdk1.8.0_65.tar.gz / opt > 56ef4a5d806cStep 6 y install vim 15: RUN yum-y install vim-- > Running in 96d23e66cbc6Loaded plugins: fastestmirror OvlDetermining fastest mirrors * base: mirrors.aliyun.com * extras: mirrors.aliyun.comStep 7 Running in 55ba5490990aRemoving intermediate container 55ba5490990a 15: ENV MYPATH / opt-- > Running in f8b147007a67Removing intermediate container f8b147007a67-- > 88cd40f1df40Step 8lem15: WORKDIR $MYPATH-- > Running in 55ba5490990aRemoving intermediate container 55ba5490990a-- > 2bdeb9172d40Step 9 Running in 55ba5490990aRemoving intermediate container 55ba5490990a 15: ENV JAVA_HOME/ opt/jdk1.8.0_65-> Running in e5edb170b825Removing intermediate container e5edb170b825-- > 2b315b03c617Step 10 Legend 15: ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools. Jar-- > Running in a3c6d7e8a539Removing intermediate container a3c6d7e8a539-- > 5a49c2cefc2aStep 11 PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/bin 15: ENV CATALINA_HOME/ opt/atlassian-confluence-6.11.0-> Running in 6c105a803c9cRemoving intermediate container 6c105a803c9c-- > 8a4879a4d399Step 12 opt/atlassian-confluence-6.11.0 15: ENV CATALINA_BASE / opt/atlassian-confluence-6.11.0-> Running in 894570c08307Removing intermediate container 894570c08307-> 843b28783e33Step 13 843b28783e33Step 15: ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/bin-- > Running in 14ea7d7ae882Removing intermediate container 14ea7d7ae882-> 2fbdf4cb96b6Step 14 shock 15: EXPOSE 8080-> Running in 0b55f91baea1Removing intermediate container 0b55f91baea1-> 340b421dfc43Step 15 + 15: CMD / opt/atlassian-confluence-6.11.0/bin/startup.sh & & tail-F / opt/atlassian-confluence-6.11.0/logs/catalina.out-- > Running in 551c8481362eRemoving intermediate container 551c8481362e-- > 4edb0a9de409Successfully built 4edb0a9de409Successfully tagged tomcat9:latest [root@t-docker tomcat9] # [root@t-docker tomcat9] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEtomcat9 latest 4edb0a9de409 3 minutes ago 1.3GB
6 、 run
[root@t-docker tomcat9] # docker run-d-p 9080 volume/test:/opt/atlassian-confluence-6.11.0/test 8090-- name myt9\-v / volume/test:/opt/atlassian-confluence-6.11.0/test\-v / volume/tomcatlogs:/opt/atlassian-confluence-6.11.0/logs\-- privileged=true\ tomcat9
-v means data volume, volume
[root@t-docker tomcat9] # docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESa4174d4abeba tomcat9 "/ bin/sh-c'/ opt/at …" 7 seconds ago Up 6 seconds 8080/tcp, 0.0.0.0 8090/tcp myt9 9080->
7. Verification
[root@t-docker tomcat9] # docker exec a4174d4abeba ls-ltotal 0drwxr-xr-x 1 1000 1000 42 Sep 2 03:41 atlassian-confluence-6.11.0-rw-r--r-- 1 root root 0 Sep 2 02:38 container.txtdrwxr-xr-x 9 root root 268 Feb 24 2016 jdk1.8.0_65drwxr-x--- 2 root root 1000 Sep 2 03:41 logs
8. Synthesize the container volume mentioned above to test the release of the web service
In the future, you can publish the version in / volume/test on the host, and the specific test will be brief.
[root@t-docker tomcat9] # cd / volume/test
[root@t-docker test] # mkdir WEB-INF
[root@t-docker test] # cd WEB-INF/
The above is all the contents of the article "how to customize tomcat Images in Dockerfile in docker". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.