Docker部署网站之后映射域名
2019-08-16 12:35:19来源:博客园 阅读 ()
Docker部署网站之后映射域名
Docker中部署tomcat相信大家也都知道,不知道的可以google 或者bing 一下。这里主要是为了记录在我们启动容器之后,tomcat需要直接定位到网站信息,而不是打开域名之后,还得加个blog后缀才能访问到我们的网站首页。
Docker exec -it [容器id] bash
进到/usr/local/tomcat/conf/
修改 server.xml。
在我们安装完docker容器,第一次进到容器内部的时候,是没有vi命令的,需要我们进行安装。
执行apt-get install vi/vim
会报以下问题。
root@4c160951c197:/usr/local/tomcat/conf# apt-get install vi
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package vi
执行apt-get update
,这个命令的作用是:同步 /etc/apt/sources.list 和 /etc/apt/sources.list.d 中列出的源的索引,这样才能获取到最新的软件包。
root@4c160951c197:~# apt-get install vim
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libgpm2 vim-common vim-runtime xxd
Suggested packages:
gpm ctags vim-doc vim-scripts
The following NEW packages will be installed:
libgpm2 vim vim-common vim-runtime xxd
0 upgraded, 5 newly installed, 0 to remove and 3 not upgraded.
Need to get 6769 kB of archives.
After this operation, 31.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://deb.debian.org/debian stretch/main amd64 libgpm2 amd64 1.20.4-6.2+b1 [34.2 kB]
Get:2 http://security.debian.org/debian-security stretch/updates/main amd64 xxd amd64 2:8.0.0197-4+deb9u3 [132 kB]
Get:3 http://security.debian.org/debian-security stretch/updates/main amd64 vim-common all 2:8.0.0197-4+deb9u3 [159 kB]
Get:4 http://security.debian.org/debian-security stretch/updates/main amd64 vim-runtime all 2:8.0.0197-4+deb9u3 [5409 kB]
Get:5 http://security.debian.org/debian-security stretch/updates/main amd64 vim amd64 2:8.0.0197-4+deb9u3 [1034 kB]
Fetched 6769 kB in 3min 54s (28.8 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package xxd.
(Reading database ... 12446 files and directories currently installed.)
Preparing to unpack .../xxd_2%3a8.0.0197-4+deb9u3_amd64.deb ...
Unpacking xxd (2:8.0.0197-4+deb9u3) ...
Selecting previously unselected package vim-common.
Preparing to unpack .../vim-common_2%3a8.0.0197-4+deb9u3_all.deb ...
Unpacking vim-common (2:8.0.0197-4+deb9u3) ...
Selecting previously unselected package libgpm2:amd64.
Preparing to unpack .../libgpm2_1.20.4-6.2+b1_amd64.deb ...
Unpacking libgpm2:amd64 (1.20.4-6.2+b1) ...
Selecting previously unselected package vim-runtime.
Preparing to unpack .../vim-runtime_2%3a8.0.0197-4+deb9u3_all.deb ...
Adding 'diversion of /usr/share/vim/vim80/doc/help.txt to /usr/share/vim/vim80/doc/help.txt.vim-tiny by vim-runtime'
Adding 'diversion of /usr/share/vim/vim80/doc/tags to /usr/share/vim/vim80/doc/tags.vim-tiny by vim-runtime'
Unpacking vim-runtime (2:8.0.0197-4+deb9u3) ...
Selecting previously unselected package vim.
Preparing to unpack .../vim_2%3a8.0.0197-4+deb9u3_amd64.deb ...
Unpacking vim (2:8.0.0197-4+deb9u3) ...
Processing triggers for mime-support (3.60) ...
Setting up xxd (2:8.0.0197-4+deb9u3) ...
Setting up libgpm2:amd64 (1.20.4-6.2+b1) ...
Processing triggers for libc-bin (2.24-11+deb9u4) ...
Setting up vim-common (2:8.0.0197-4+deb9u3) ...
Setting up vim-runtime (2:8.0.0197-4+deb9u3) ...
Setting up vim (2:8.0.0197-4+deb9u3) ...
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdiff) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rvim (rvim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rview (rview) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vi (vi) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/view (view) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/ex (ex) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/editor (editor) in auto mode
root@4c160951c197:~# cd /usr/local/tomcat/conf/
修改/usr/local/tomcat/conf/server.xml
...
<!--修改defaultHost-->
<Engine name="Catalina" defaultHost="life-runner.com">
...
<!--改变appBase对应的目录-->
<Host name="life-runner.com" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<!--添加文件appBase对应的目录-->
<Context path="" docBase ="../webapps/blog/"/>
</Host>
...
重启blog容器
# [root@sxzhongf-test tmp]# docker run -d -p 80:8080 isaac-blog:1.0 启动容器
[root@sxzhongf-test tmp]# docker restart [容器id]
原文链接:https://www.cnblogs.com/zhangpan1244/p/11354628.html
如有疑问请与原作者联系
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- IDEA 设置热部署 Devtools 2020-06-10
- 详解SpringBoot(2.3)应用制作Docker镜像(官方方案) 2020-06-08
- 体验SpringBoot(2.3)应用制作Docker镜像(官方方案) 2020-06-07
- Centos下Zookeeper的安装部署 2020-06-06
- Java高级实战Maven+JSP+SSM+Mysql实现的音乐网站,70%人不会 2020-06-04
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash