
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
该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 \ docker.xuanyuan.run/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 \ docker.xuanyuan.run/cityseer/postgis:latest
SSL证书生成示例(使用Let's Encrypt)
bash# 安装acme.sh sudo apt-get install wget cron netcat wget -O - https://get.acme.sh | 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 = 10485kBmin_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存储、更大内存)调整参数。
https://hub.docker.com/r/cityseer/postgis/
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务
以下是 cityseer/postgis 相关的常用 Docker 镜像,适用于 不同场景 等不同场景: