
cityseer/postgis该Docker镜像基于Postgres 11构建,集成了PostGIS 2.5.2、SFCGAL、pgrouting 2.6.2等地理空间扩展,并支持光栅数据处理和SSL连接。适用于需要地理空间数据存储和分析的应用场景。
Docker Hub镜像标签及对应版本信息:
latest:Postgres 11 + PostGIS 2.5.2 + SFCGAL 1.3.7 + pgrouting 2.6.22.5:同上2.5_10:Postgres 10 + PostGIS 2.5.2 + SFCGAL 1.3.7 + pgrouting 2.6.22.4:Postgres 10 + PostGIS 2.4.5 + SFCGAL 1.3.6 + pgrouting 2.6.12.3:Postgres 9.6 + PostGIS 2.3.7 + SFCGAL 1.3.6 + pgrouting 2.6.1容器默认映射数据卷路径:/postgresql/11/main(不同版本对应不同Postgres版本路径,如2.5_10使用/postgresql/10/main,2.3使用/postgresql/9.6/main)。
可通过以下环境变量配置新数据库:
| 环境变量 | 默认值 | 描述 |
|---|---|---|
PG_USER | my_username | 数据库角色(用户)名 |
PG_PASSWORD | 无 | 可选密码 |
DB_NAME | my_db | 新数据库名称 |
新用户拥有数据库的一般权限,并被授予
postgres超级用户成员资格,可通过SET ROLE postgres;临时获取超级用户权限,完成管理任务后用RESET ROLE;重置。
容器暴露5432端口,需映射至本地端口才能通过localhost:5432连接,例如-p 5432:5432。
postgresql.conf中listen_addresses需设为'*'pg_hba.conf需包含以下配置:
local all all trust host all all 0.0.0.0/0 trust
bashdocker run -d -p 5432:5432 \ -e "PG_USER=my_username" \ -e "PG_PASSWORD=my_password" \ -e "DB_NAME=my_db" \ --restart=unless-stopped \ --volume=/path/to/local/data:/postgresql/11/main \ cityseer/postgis:latest
查看日志:
bashdocker logs -f <容器ID>
若使用已有配置数据库,可省略环境变量,新数据库初始化时未指定环境变量将使用默认值。
server.crt(证书)和server.key(密钥)文件,放置于本地目录bashdocker run -d -p 5432:5432 \ -e "PG_USER=my_username" \ -e "PG_PASSWORD=my_password" \ -e "DB_NAME=my_db" \ --restart=unless-stopped \ --volume=/path/to/local/data:/postgresql/11/main \ --volume=/path/to/local/ssl:/postgresql/11/ssl \ cityseer/postgis:latest
bash# 安装acme.sh sudo apt-get install wget cron netcat wget -O - [***] | sh # 生成证书 sudo ~/.acme.sh/acme.sh --issue --standalone -d your_domain.com # 安装证书到指定目录 mkdir /path/to/local/ssl ~/.acme.sh/acme.sh --installcert -d your_domain.com \ --certpath /path/to/local/ssl/server.crt \ --keypath /path/to/local/ssl/server.key sudo chmod 0600 /path/to/local/ssl/server.key
默认配置基于pgtune优化,适用于4GB内存、50连接数、HDD存储的混合工作负载,通过ALTER SYSTEM命令写入postgresql.auto.conf(覆盖postgresql.conf默认设置):
max_connections = 50shared_buffers = 1GBeffective_cache_size = 3GBmaintenance_work_mem = 256MBcheckpoint_completion_target = 0.9wal_buffers = 16MBdefault_statistics_target = 100random_page_cost = 4effective_io_concurrency = 2work_mem = ***kBmin_wal_size = 1GBmax_wal_size = 2GB通过ALTER SYSTEM命令修改配置(需postgres超级用户权限):
sqlSET ROLE postgres; ALTER SYSTEM SET max_connections = '100'; -- 修改连接数 RESET ROLE; SELECT pg_reload_conf(); -- 重载配置
验证配置:
sqlSELECT current_setting('max_connections');
建议根据实际环境(如SSD存储、更大内存)调整参数。
cityseer/postgis


manifest unknown 错误
TLS 证书验证失败
DNS 解析超时
410 错误:版本过低
402 错误:流量耗尽
身份认证失败错误
429 限流错误
凭证保存错误
来自真实用户的反馈,见证轩辕镜像的优质服务