Docker Compose 部署Nginx反向代理 tomcat

Nginx 、Tomcat (默认端口8080)》》compose

csharp 复制代码
services:
  nginx:
    image: nginx:latest
    container_name: nginx
    restart: always
    ports:
      - 80:80
      - 8080:8080
    volumes:
      # 文件夹会自动创建,但nginx.conf是文件,需要提前创建,否则 会自动创建nginx.conf文件夹
      - ./conf/nginx.conf:/etc/nginx/nginx.conf
      - ./html:/usr/share/nginx/html
  tomcat1:
    image: tomcat:latest
    container_name: tomcat1

  tomcate2:
    image: tomcat:latest
    container_name: tomcat2

nginx的配置文件

csharp 复制代码
worker_processes  2;

events {
    worker_connections  1024;
}

http {
   upstream httpd {
        server tomcat1:8080 weight=10;
        server tomcat2:8080 weight=10;
   }
   include       mime.types;
   default_type  application/octet-stream;

   sendfile        on;

   server {
       listen       80;
       #  为了模拟域名访问,  需要在访问的客户端 host 加   IP  service.zen.com
       server_name  service.zen.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
          proxy_pass http://httpd;
        }

    }

}

运行 compose

csharp 复制代码
#  运行 compose
docker compose up -d

# 查看运行的容器进程
docker ps

# 因tomcat 拉取 阿里云的, 阿里云是处理过的 ,保留核心的内容了
# 进入tomcat 容器
docker exec -it tomcat容器ID   /bin/bash
# 阿里云拉取的 tomcat   /usr/local/tomcat/webapps  是空的 阿里云把内容 存在 webapps.dist文件夹里了
cp -r  webapps.dist/* webapps/


相关推荐
杨浦老苏1 天前
开源多用户图书追踪系统LibrisLog
docker·群晖·收藏管理
赵渝强老师1 天前
【赵渝强老师】Kubernetes(K8s)中的金丝雀升级
linux·docker·云原生·容器·kubernetes
sinat_255487811 天前
第七部分。介绍MVC(模型-视图-控制器)模式
java·ide·http·tomcat·intellij-idea
我叫张小白。1 天前
CentOS 7 安装 Docker并配置镜像加速(完整指南)
linux·docker·centos
原来是猿1 天前
Docker 【 技术架构(1)】
docker·容器·架构
前端程序猿i1 天前
Nginx 教程:从入门到能上线
运维·nginx
明辰之林1 天前
Nginx 1.26.2 → 1.30.2 升级指南(离线环境)
nginx
木雷坞1 天前
Qdrant Docker 部署教程:数据卷、API Key 和集合初始化
运维·docker·容器·知识图谱
梦梦代码精1 天前
为什么这个开源的AI平台会火?有点东西。。。
人工智能·算法·机器学习·docker·开源
Lv_沐曦1 天前
银河麒麟桌面版安装、多屏配置、触摸校准
运维·docker·samba·vsftpd·银河麒麟·触控校准·多屏配置