两种方式:

1.直接部署geoserver为一个服务

docker-compose文件:

version: '3'

services:
geoserver:
restart: always
image: thinkwhere/geoserver
container_name: geoserver
volumes:
- "./data_dir:/opt/geoserver/data_dir"
ports:
- '18081:8080'
environment:
- 'GEOSERVER_LOG_LOCATION=/opt/geoserver/data_dir/logs'
- 'TZ=Asia/Shanghai'

 

2.用docker部署tomcat,然后将geoserver的war包放到docker部署的tomcat中:

tomcat的docker-compose文件:

version: '3'
services:
tomcat:
restart: always
image: tomcat
container_name: tomcat
ports:
- 18082:8080
volumes:
- ./courage/:/usr/local/tomcat/webapps/
environment:
TZ: Asia/Shanghai

成功启动后会在docker-compose文件的目录下生成courage文件夹,将geoserver的war放入该文件夹即可。