【问题标题】:Docker-compose with postgres with geography postgis not workingDocker-compose 与 postgres 与地理 postgis 不工作
【发布时间】:2019-07-04 19:36:44
【问题描述】:

我正在使用一个运行烧瓶应用程序的 docker-compose 容器。在这个容器中,一个带有 Postgis 扩展(mdillon/postgis 图像)的 postgres 容器被启动。一切运行良好,但单个 Postgis 扩展(地理)不起作用,我无法解释。

我的 docker-compose.yml:

version: '3.7'
services:
  flask:
    build: .
    entrypoint:
      - flask
      - run
      - --host=0.0.0.0
    environment:
      FLASK_DEBUG: 1
      FLASK_APP: app.py
    ports:
      - '5000:5000'
    volumes:
      - './app:/app'
    networks:
      - db_net
  db:
    image: mdillon/postgis
    networks:
      - db_net

networks:
  db_net:

运行sudo docker-compose up --build 后,它会创建两个容器:

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                     NAMES
1836d3d15765        img_flask         "flask run --host=0.…"   9 minutes ago       Up 9 minutes        80/tcp, 443/tcp, 0.0.0.0:5000->5000/tcp   img_flask_1
b25752af45ad        mdillon/postgis     "docker-entrypoint.s…"   13 minutes ago      Up 13 minutes       5432/tcp                                  img_db_1

打开烧瓶应用程序或数据库日志时,它声称以下内容:

sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedObject) type "geography" does not exist
LINE 7:  geom geography(POINT,4326)

检查 postgis 是否正确并在数据库中重新安装它并不能解决它。包如下:

                                            List of installed extensions
          Name          | Version |   Schema   |                             Description                             
------------------------+---------+------------+---------------------------------------------------------------------
 fuzzystrmatch          | 1.1     | public     | determine similarities and distance between strings
 plpgsql                | 1.0     | pg_catalog | PL/pgSQL procedural language
 postgis                | 2.5.0   | public     | PostGIS geometry, geography, and raster spatial types and functions
 postgis_tiger_geocoder | 2.5.0   | tiger      | PostGIS tiger geocoder and reverse geocoder
 postgis_topology       | 2.5.0   | topology   | PostGIS topology spatial types and functions
(5 rows)

总结一下,我的容器运行良好,并且 Postgis 安装良好。但是当查询请求 Geography 函数时会出现问题。有没有人可以就如何解决这个问题提供建议?谢谢!

【问题讨论】:

  • 运行查询的用户是否在运行查询的会话中的 search_path 中有 public?
  • @Jeremy; search_path 确实是公开的:postgres=# SHOW search_path; search_path ----------------- public (1 row)
  • 已修复,意外在不同的数据库中工作。 @Jeremy 谢谢!

标签: postgresql docker-compose postgis


【解决方案1】:

已修复,不小心在不同的数据库中工作。 @Jeremy 谢谢!

【讨论】:

    猜你喜欢
    • 2022-10-16
    • 1970-01-01
    • 2018-11-18
    • 2017-08-06
    • 1970-01-01
    • 2014-02-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多