技术流ken

运维拯救世界

实战项目:docker容器运行tomcat并上线网站–技术流ken

项目docker容器运行tomcat并上线网站

1.使用docker部署tomcat环境
2.上线博客网站
3.完成访问使用等

 

第一步:启动基于tomcat镜像的容器

[root@ken1 ~]# docker run -d -p 89:8080 kubeguide/tomcat-app:v1
b429c9ed543ffe3d7dfb6549ab528b843ea76776d737b76c51a073b348bcab34
[root@ken1 ~]# docker ps
CONTAINER ID        IMAGE                     COMMAND              CREATED             STATUS              PORTS                   NAMES
b429c9ed543f        kubeguide/tomcat-app:v1   "catalina.sh run"    3 seconds ago       Up 1 second         0.0.0.0:89->8080/tcp    interesting_babbage

 

第二步:清空容器tomcat网站根目录内容、

[root@ken1 ~]# docker exec -it b429c9ed543f  bash  #进入容器
root@b429c9ed543f:/usr/local/tomcat# ls #查看文件
LICENSE  NOTICE  RELEASE-NOTES	RUNNING.txt  bin  conf	include  lib  logs  temp  webapps  work
root@b429c9ed543f:/usr/local/tomcat# cd webapps/  #切换至tomcat网站根目录
root@b429c9ed543f:/usr/local/tomcat/webapps# ls  #查看是当前目录内容
ROOT  demo  docs  examples  host-manager  manager
root@b429c9ed543f:/usr/local/tomcat/webapps# cd ROOT  #切换至ROOT目录下
root@b429c9ed543f:/usr/local/tomcat/webapps/ROOT# ls
RELEASE-NOTES.txt  asf-logo.png   bg-nav-item.png  build.xml	tomcat-power.gif  tomcat.png
WEB-INF		   bg-button.png  bg-nav.png	   favicon.ico	tomcat.css	  tomcat.svg
asf-logo-wide.gif  bg-middle.png  bg-upper.png	   index.jsp	tomcat.gif
root@b429c9ed543f:/usr/local/tomcat/webapps/ROOT# rm -rf *  #删除ROOT下所有的内容

 

第三步:复制网站文件至tomcat网站根目录

[root@ken1 ~]# docker cp fuhai-jpress-alpha.zip b429c9ed543f:/usr/local/tomcat/webapps/ROOT

 

第四步:进入容器解压网站内容


root@b429c9ed543f:/usr/local/tomcat/webapps/ROOT# cd webapps/ROOT/
root@b429c9ed543f:/usr/local/tomcat/webapps/ROOT# ls
root@b429c9ed543f:/usr/local/tomcat/webapps/ROOT# unzip fuhai-jpress-alpha.zip 
root@b429c9ed543f:/usr/local/tomcat/webapps/ROOT# ls
root@b429c9ed543f:/usr/local/tomcat/webapps/ROOT# cp jpress/wars/jpress-web-newest.war  .
root@b429c9ed543f:/usr/local/tomcat/webapps/ROOT# ls
root@b429c9ed543f:/usr/local/tomcat/webapps/ROOT# unzip jpress-web-newest.war 
root@b429c9ed543f:/usr/local/tomcat/webapps/ROOT# ls
META-INF  WEB-INF  fuhai-jpress-alpha.zip  jpress  jpress-web-newest.war  robots.txt  static  templates

 

第五步:配置数据库

MariaDB [(none)]> create database jpress;
MariaDB [(none)]> grant all on *.* to jpress@'%' identified by '123';

 

第六步:浏览器再次访问网站 #数据库部署在宿主机之上!!!

填入数据库名

数据库用户及密码

输入数据库地址192.168.64.5

数据库端口3306

8 thoughts on “实战项目:docker容器运行tomcat并上线网站–技术流ken

  1. I and also my guys came looking through the good tips and hints from the website and the sudden I had a terrible suspicion I never expressed respect to the web blog owner for those secrets. All the guys were definitely as a consequence very interested to see them and have in actuality been having fun with them. Appreciate your genuinely indeed helpful and also for making a choice on variety of impressive useful guides most people are really needing to discover. Our honest regret for not expressing gratitude to you earlier.

  2. My husband and i felt very fortunate when Ervin could carry out his researching with the ideas he got while using the weblog. It’s not at all simplistic to simply always be offering tactics which usually others might have been making money from. And we take into account we now have you to appreciate for that. The most important explanations you made, the easy site menu, the relationships you will aid to promote – it is most spectacular, and it’s letting our son in addition to us know that the situation is fun, which is seriously fundamental. Thanks for all!

  3. I’m just commenting to make you understand what a remarkable experience my daughter experienced using the blog. She even learned lots of things, most notably what it’s like to possess a marvelous helping character to get the mediocre ones quite simply know just exactly some problematic things. You actually exceeded our desires. I appreciate you for producing those good, dependable, educational as well as unique tips on this topic to Sandra.

  4. I simply wanted to compose a quick note to express gratitude to you for some of the fantastic guidelines you are giving out at this site. My time-consuming internet investigation has finally been rewarded with awesome suggestions to write about with my guests. I would suppose that many of us site visitors actually are unequivocally blessed to be in a magnificent community with so many marvellous people with good tricks. I feel really lucky to have encountered your site and look forward to tons of more pleasurable minutes reading here. Thank you once again for a lot of things.

  5. I simply needed to thank you very much all over again. I do not know the things that I might have followed without these pointers contributed by you regarding that situation. It absolutely was a real alarming dilemma in my opinion, nevertheless discovering a new expert avenue you processed it made me to leap with fulfillment. I’m grateful for this help and then expect you know what a great job you happen to be accomplishing training people thru your websites. I am sure you’ve never encountered all of us.

  6. Thanks a lot for providing individuals with an extraordinarily memorable possiblity to check tips from this web site. It is usually very beneficial and packed with amusement for me and my office colleagues to search your website minimum three times in 7 days to find out the newest guidance you will have. And definitely, we are actually contented with all the amazing tricks served by you. Selected 4 points in this article are surely the very best we have all ever had.

  7. I definitely wanted to write down a small note to be able to thank you for these awesome instructions you are showing here. My time intensive internet search has at the end been paid with brilliant content to go over with my friends. I would point out that we readers are quite fortunate to dwell in a fine network with very many wonderful professionals with useful advice. I feel rather happy to have come across the webpages and look forward to some more thrilling times reading here. Thank you again for a lot of things.

发表评论

电子邮件地址不会被公开。