1. Docker compose
2. Docker Compose部署项目
version: "3.8"
services:
mysql:
image: mysql
container_name: mysql
ports:
- "3307:3306"
environment:
TZ: Asia/Shanghai
MYSQL_ROOT_PASSWORD: 123
volumes:
- "/root/docker/mysql/conf:/etc/mysql/conf.d"
- "/root/docker/mysql/data:/var/lib/mysql"
- "/root/docker/mysql/init:/docker-entrypoint-initdb.d"
networks:
- hm-net
hmall:
build:
context: .
dockerfile: Dockerfile
container_name: hmall
ports:
- "8088:8080"
networks:
- hm-net
depends_on:
- mysql
nginx:
image: nginx
container_name: nginx
ports:
- "18080:18080"
- "18081:18081"
volumes:
- "/root/docker/nginx/nginx.conf:/etc/nginx/nginx.conf"
- "/root/docker/nginx/html:/usr/share/nginx/html"
depends_on:
- hmall
networks:
- hm-net
networks:
hm-net:
name: hmall
-
- 执行
docker compose up -d
-
- 结束所有
docker compose down