version: '2'
services:
tomcat:
build: .
ports:
- "8080:8080"
- "5005:5005"
volumes:
- tomcat:/usr/local/tomcat
volumes:
tomcat:
driver: local
driver_opts:
type: none
device: /root/tomcat
o: bind
其中/root/tomcat可以修改为你要映射的路径
来源:https://stackoverflow.com/a/53200495/10096812