【发布时间】:2020-10-07 10:47:08
【问题描述】:
我为 Geoserver 和 Postgis 使用了 kartoza's docker 镜像,并使用提供的 docker-compose.yml 在两个 docker 容器中启动它们:
version: '2.1'
volumes:
geoserver-data:
geo-db-data:
services:
db:
image: kartoza/postgis:12.0
volumes:
- geo-db-data:/var/lib/postgresql
ports:
- "25434:5432"
env_file:
- docker-env/db.env
restart: on-failure
healthcheck:
test: "exit 0"
geoserver:
image: kartoza/geoserver:2.17.0
volumes:
- geoserver-data:/opt/geoserver/data_dir
ports:
- "8600:8080"
restart: on-failure
env_file:
- docker-env/geoserver.env
depends_on:
db:
condition: service_healthy
healthcheck:
test: curl --fail -s http://localhost:8080/ || exit 1
interval: 1m30s
timeout: 10s
retries: 3
引用的 .env 文件是:
db.env
POSTGRES_DB=gis,gwc
POSTGRES_USER=docker
POSTGRES_PASS=docker
ALLOW_IP_RANGE=0.0.0.0/0
geoserver.env
GEOSERVER_DATA_DIR=/opt/geoserver/data_dir
ENABLE_JSONP=true
MAX_FILTER_RULES=20
OPTIMIZE_LINE_WIDTH=false
FOOTPRINTS_DATA_DIR=/opt/footprints_dir
GEOWEBCACHE_CACHE_DIR=/opt/geoserver/data_dir/gwc
GEOSERVER_ADMIN_PASSWORD=myawesomegeoserver
INITIAL_MEMORY=2G
MAXIMUM_MEMORY=4G
XFRAME_OPTIONS='false'
STABLE_EXTENSIONS=''
SAMPLE_DATA=false
GEOSERVER_CSRF_DISABLED=true
docker-compose up 使两个容器都启动并运行,并且没有错误地为它们命名backend_db_1(Postgis)和backend_geoserver_1(Geoserver)。我可以按预期访问在backend_geoserver_1 下http://localhost:8600/geoserver/ 下运行的Geoserver。我可以毫无问题地将基于 AWS 的外部 Postgis 作为数据存储连接到基于 docker 的 Geoserver 实例。我还可以从 PgAdmin 访问在 docker 容器 backend_db_1 中运行的 Postgis,从命令行和 Webstorm IDE 使用 psql。
但是,如果我尝试将在 backend_db_1 中运行的 Postgis 用作在 backend_geoserver_1 中运行的 Geoserver 的数据存储,则会收到以下错误:
> Error creating data store, check the parameters. Error message: Unable
> to obtain connection: Cannot create PoolableConnectionFactory
> (Connection to localhost:25434 refused. Check that the hostname and
> port are correct and that the postmaster is accepting TCP/IP
> connections.)
所以,我在backend_geoserver_1 中的 Geoserver 可以连接到 AWS 上的 Postgis,但不能连接到在同一 localhost 上的另一个 docker 容器中运行的那个。 backend_db_1 中的 Postgis 可以从许多其他本地应用程序和工具访问,但不能从运行在 docker 容器中的 Geoserver 访问。
任何想法我错过了什么?谢谢!
【问题讨论】:
标签: linux docker postgis geoserver