docker-compose.yml的配置如下
version: '3.3'
services:
myweb:
restart: always
image: tomcat
container_name: myweb
ports:
- 8888:8080
volumes:
- ./tomcat/webapps:/usr/local/tomcat/webapps
- ./tomcat/logs:/usr/local/tomcat/logs
mysql:
restart: always
image: mysql
container_name: mysql
ports:
- 3310:3306
environment:
TZ: Asia/Shanghai
MYSQL_ROOT_PASSWORD: 123456
command:
--default-authentication-plugin=mysql_native_password
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
--explicit_defaults_for_timestamp=true
--lower_case_table_names=1
--max_allowed_packet=128M
volumes:
- ./mysql/data:/var/lib/mysql
- ./mysql/conf/my.cnf:/etc/my.cnf
- ./mysql/init:/docker-entrypoint-initdb.d/
- ./mysql/logs:/var/log/mysql
将tomcat的放应用的目录和mysql的数据库目录挂载了出来