编辑文件
version: "3"
services:
umps:
# 指定容器名称
container_name: umps
# 重启机制
# restart: always
image: openjdk:11
volumes:
# 本地jar包路径
- /home/service/app/yshop-upms.jar:/yshop-upms.jar
# 挂载日志 -v A:B ,A指宿主机位置,B指容器位置
- /home/service/app/logs/yshop-upms:/logs/yshop-upms
# 指定容器时间为宿主机时间
- /etc/localtime:/etc/localtime
# 访问端口
ports:
- "9201:9201"
environment:
# 指定时区
- TZ="Asia/Shanghai"
# 启动容器后执行的命令
entrypoint: java -jar yshop-upms.jar
extra_hosts:
- "nacos:192.168.120.220"
- "rabbitmq:192.168.120.220"
- "sentinel:192.168.120.220"
- "redis:192.168.120.220"
- "mysql:192.168.120.220"
network_mode: "host"
mall:
# 指定容器名称
container_name: mall
# 重启机制
# restart: always
image: openjdk:11
volumes:
# 本地jar包路径
- /home/service/app/yshop-mall.jar:/yshop-mall.jar
# 挂载日志 -v A:B ,A指宿主机位置,B指容器位置
- /home/service/app/logs/yshop-mall:/logs/yshop-mall
# 指定容器时间为宿主机时间
- /etc/localtime:/etc/localtime
# 访问端口
ports:
- "9202:9202"
environment:
# 指定时区
- TZ="Asia/Shanghai"
# 启动容器后执行的命令
entrypoint: java -jar yshop-mall.jar
extra_hosts:
- "nacos:192.168.120.220"
- "rabbitmq:192.168.120.220"
- "sentinel:192.168.120.220"
- "redis:192.168.120.220"
- "mysql:192.168.120.220"
network_mode: "host"
weixin:
# 指定容器名称
container_name: weixin
# 重启机制
# restart: always
image: openjdk:11
volumes:
# 本地jar包路径
- /home/service/app/yshop-weixin.jar:/yshop-weixin.jar
# 挂载日志 -v A:B ,A指宿主机位置,B指容器位置
- /home/service/app/logs/yshop-weixin:/logs/yshop-weixin
# 指定容器时间为宿主机时间
- /etc/localtime:/etc/localtime
# 访问端口
ports:
- "8001:8001"
environment:
# 指定时区
- TZ="Asia/Shanghai"
# 启动容器后执行的命令
entrypoint: java -jar yshop-weixin.jar
extra_hosts:
- "nacos:192.168.120.220"
- "rabbitmq:192.168.120.220"
- "sentinel:192.168.120.220"
- "redis:192.168.120.220"
- "mysql:192.168.120.220"
network_mode: "host"
auth:
# 指定容器名称
container_name: auth
# 重启机制
# restart: always
image: openjdk:11
volumes:
# 本地jar包路径
- /home/service/app/yshop-auth.jar:/yshop-auth.jar
# 挂载日志 -v A:B ,A指宿主机位置,B指容器位置
- /home/service/app/logs/yshop-auth:/logs/yshop-auth
# 指定容器时间为宿主机时间
- /etc/localtime:/etc/localtime
# 访问端口
ports:
- "9200:9200"
environment:
# 指定时区
- TZ="Asia/Shanghai"
# 启动容器后执行的命令
entrypoint: java -jar yshop-auth.jar
extra_hosts:
- "nacos:192.168.120.220"
- "rabbitmq:192.168.120.220"
- "sentinel:192.168.120.220"
- "redis:192.168.120.220"
- "mysql:192.168.120.220"
network_mode: "host"
gateway:
# 指定容器名称
container_name: gateway
# 重启机制
# restart: always
image: openjdk:11
volumes:
# 本地jar包路径
- /home/service/app/yshop-gateway.jar:/yshop-gateway.jar
# 挂载日志 -v A:B ,A指宿主机位置,B指容器位置
- /home/service/app/logs/yshop-gateway:/logs/yshop-gateway
# 指定容器时间为宿主机时间
- /etc/localtime:/etc/localtime
# 访问端口
ports:
- "8081:8081"
environment:
# 指定时区
- TZ="Asia/Shanghai"
# 启动容器后执行的命令
entrypoint: java -jar yshop-gateway.jar
extra_hosts:
- "nacos:192.168.120.220"
- "rabbitmq:192.168.120.220"
- "sentinel:192.168.120.220"
- "redis:192.168.120.220"
- "mysql:192.168.120.220"
network_mode: "host"
上传jar包
# 启动
docker-compose -f docker-compose.yaml up -d
# 删除
docker-compose -f docker-compose.yaml down