场景
Docker-Compose简介与Ubuntu Server 上安装Compose:
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/100902301
Docker Compose基本使用-使用Compose启动Tomcat为例:
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/100904080
Docker Compose部署项目到容器-基于Tomcat和mysql的商城项目(附源码和sql下载):
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/100941366
实现
version: ''
services:
web:
restart: always
image: tomcat
container_name: web
ports:
- :
volumes:
- /usr/local/docker/myshop/ROOT:/usr/local/tomcat/webapps/ROOT mysql:
restart: always
image: mysql:5.7.
container_name: mysql
ports:
- :
environment:
TZ: Asia/Shanghai
MYSQL_ROOT_PASSWORD:
command:
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
--explicit_defaults_for_timestamp=true
--lower_case_table_names=
--max_allowed_packet=128M
--sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO"
volumes:
- mysql-data:/var/lib/mysql volumes:
mysql-data:
注:
这里是mysql5.7.22