docker搭建ngnix与tomcat

nginx

1、nginx容器的html在目录:/usr/share/nginx/html
2、nginx.conf在容器默认位置:/etc/nginx/nginx.conf
nginx.conf需要
server {
location / {
root /usr/share/nginx/dist;
}
}
注意root需要写绝对路径
root 设置的是 location 匹配访问路径的上一层目录,location后面的/是匹配规则。
docker run 挂载项目文件夹dist到容器内的/usr/share/nginx/dist,
如果将配置文件-v到/etc/nginx/nginx.conf,则无需以配置文件启动

完整docker run:docker run --name nginx -p 80:80 -v /opt/nginx/dist/:/usr/share/nginx/dist -v /opt/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -d 镜像id
3、nginx的/etc/nginx/nginx.conf的http内include /etc/nginx/conf.d/*.conf;即
在/etc/nginx/有conf.d目录,即nginx.conf把server部分拆到conf.d目录下,此目录下存放虚拟主机的配置文件,参考:https://www.cnblogs.com/fps2tao/p/9958009.html
4、采用更改挂载到外面的文件更新方式,需要重启nginx容器

tomcat

日志位置:/usr/local/tomcat/logs
创建容器:docker run --name tomcat8.5.70 -p 8080:8080 -v /opt/docker/tomcat/logs:/usr/local/tomcat/logs -v /opt/docker/tomcat/conf:/usr/local/tomcat/conf -d 镜像id

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值