
如果你使用 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 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
https://github.com/postgis/docker-postgis/workflows/Docker%20PostGIS%20CI/badge.svg](https://github.com/postgis/docker-postgis/actions) https://badges.gitter.im/Join%20Chat.svg](https://gitter.im/postgis/docker-postgis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
⚠️ 重大变更(PostgreSQL 18+):
默认VOLUME路径已变更为/var/lib/postgresql
postgis/postgis镜像提供用于运行已安装http://postgis.net/%E6%89%A9%E5%B1%95%E7%9A%84Postgres%E7%9A%84%E6%A0%87%E7%AD%BE%E3%80%82%E8%AF%A5%E9%95%9C%E5%83%8F%E5%9F%BA%E4%BA%8E%E5%AE%98%E6%96%B9https://registry.hub.docker.com/_/postgres/%E9%95%9C%E5%83%8F%EF%BC%8C%E6%8F%90%E4%BE%9B%E9%80%82%E7%94%A8%E4%BA%8EPostgreSQL 13、14、15、16、17和18版本的PostGIS 3.5.x和3.6.x的Debian和Alpine变体。此外,还提供基于PostgreSQL 16和17的镜像变体,使用各自主分支构建PostGIS及其依赖项,标记为16-master和17-master。
此镜像确保父postgres镜像创建的默认数据库将安装以下扩展:
| 已安装扩展 | https://github.com/postgis/docker-postgis/blob/master/initdb-postgis.sh |
|---|---|
postgis | 是 |
postgis_topology | 是 |
postgis_tiger_geocoder | 是 |
postgis_raster | 否(可用) |
postgis_sfcgal | 否(可用) |
address_standardizer | 否(可用) |
address_standardizer_data_us | 否(可用) |
除非在启动容器时传递-e POSTGRES_DB,否则此数据库将以管理员用户命名(postgres或通过-e POSTGRES_USER指定的用户)。如果希望使用旧版模板数据库机制启用PostGIS,镜像还提供名为template_postgis的PostGIS启用模板数据库。
支持架构:amd64(x86-64)
新用户推荐版本:
postgis/postgis:18-3.6
/var/lib/postgresql(PostgreSQL 18+中变更)postgis/postgis:17-3.5
/var/lib/postgresql/data| DockerHub镜像 | Dockerfile | 操作系统 | PostgreSQL | PostGIS |
|---|---|---|---|---|
| https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=13-3.5 | https://github.com/postgis/docker-postgis/blob/master/13-3.5/Dockerfile | debian:bullseye | 13 | 3.5.2 |
| https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=14-3.5 | https://github.com/postgis/docker-postgis/blob/master/14-3.5/Dockerfile | debian:bullseye | 14 | 3.5.2 |
| https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=15-3.5 | https://github.com/postgis/docker-postgis/blob/master/15-3.5/Dockerfile | debian:bullseye | 15 | 3.5.2 |
| https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=16-3.5 | https://github.com/postgis/docker-postgis/blob/master/16-3.5/Dockerfile | debian:bullseye | 16 | 3.5.2 |
| https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=17-3.5 | https://github.com/postgis/docker-postgis/blob/master/17-3.5/Dockerfile | debian:bullseye | 17 | 3.5.2 |
| https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=18-3.6 | https://github.com/postgis/docker-postgis/blob/master/18-3.6/Dockerfile | debian:trixie | 18 | 3.6.1 |
| DockerHub镜像 | Dockerfile | 操作系统 | PostgreSQL | PostGIS |
|---|---|---|---|---|
| https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=13-3.5-alpine | https://github.com/postgis/docker-postgis/blob/master/13-3.5/alpine/Dockerfile | alpine:3.22 | 13 | 3.5.4 |
| https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=14-3.5-alpine | https://github.com/postgis/docker-postgis/blob/master/14-3.5/alpine/Dockerfile | alpine:3.22 | 14 | 3.5.4 |
| https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=15-3.5-alpine | https://github.com/postgis/docker-postgis/blob/master/15-3.5/alpine/Dockerfile | alpine:3.22 | 15 | 3.5.4 |
| https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=16-3.5-alpine | https://github.com/postgis/docker-postgis/blob/master/16-3.5/alpine/Dockerfile | alpine:3.22 | 16 | 3.5.4 |
| https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=17-3.5-alpine | https://github.com/postgis/docker-postgis/blob/master/17-3.5/alpine/Dockerfile | alpine:3.22 | 17 | 3.5.4 |
| https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=17-3.6-alpine | https://github.com/postgis/docker-postgis/blob/master/17-3.6/alpine/Dockerfile | alpine:3.22 | 17 | 3.6.1 |
| https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=18-3.6-alpine | https://github.com/postgis/docker-postgis/blob/master/18-3.6/alpine/Dockerfile | alpine:3.22 | 18 | 3.6.1 |
*-master镜像的模板需手动更新,可能会有几周延迟。| DockerHub镜像 | Dockerfile | 操作系统 | PostgreSQL | PostGIS |
|---|---|---|---|---|
| https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=16-master | https://github.com/postgis/docker-postgis/blob/master/16-master/Dockerfile | debian:bullseye | 16 | 开发版:postgis、geos、proj、gdal |
| https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=17-master | https://github.com/postgis/docker-postgis/blob/master/17-master/Dockerfile | debian:bullseye | 17 | 开发版:postgis、geos、proj、gdal |
要运行一个基本的PostGIS启用数据库容器,可按以下方式启动:
shdocker run --name some-postgis -e POSTGRES_PASSWORD=mysecretpassword -d postgis/postgis
有关启动和控制Postgres容器的详细说明,请参阅https://registry.hub.docker.com/_/postgres/%E3%80%82
启动数据库容器后,可直接连接到运行中的容器:
shdocker exec -ti some-postgis psql -U postgres
或启动新容器作为客户端,使用用户定义网络连接两个容器:
shdocker network create some-network # 服务端容器 docker run --name some-postgis --network some-network -e POSTGRES_PASSWORD=mysecretpassword -d postgis/postgis # 客户端容器 docker run -it --rm --network some-network postgis/postgis psql -h some-postgis -U postgres
更多连接方式详见https://registry.hub.docker.com/_/postgres/%E5%92%8Chttps://docs.docker.com/network/%E3%80%82
创建和使用空间数据库的更多选项,请参阅http://postgis.net/docs/postgis_installation.html#create_new_db_extensions%E3%80%82
由于docker-postgis是官方Docker PostgreSQL仓库的扩展,所有官方支持的环境变量在此同样适用:
POSTGRES_PASSWORDPOSTGRES_USERPOSTGRES_DBPOSTGRES_INITDB_ARGSPOSTGRES_INITDB_WALDIRPOSTGRES_HOST_AUTH_METHODPGDATA https://github.com/docker-library/docs/blob/master/postgres/README.md#pgdata详情请阅读https://github.com/docker-library/docs/blob/master/postgres/README.md
PGDATA卷路径变更从PostgreSQL 18开始,默认数据目录(VOLUME)路径已变更。这影响所有**postgis/postgis:18-***及更新镜像。
卷路径摘要:
| 镜像名称 | 镜像标签范围 | --volume路径 |
|---|---|---|
postgis/postgis | 18-* … | /var/lib/postgresql |
postgis/postgis | 13-* … 17-* | /var/lib/postgresql/data |
请为18+镜像调整卷挂载。更多详情见https://github.com/docker-library/postgres/pull/1259%E3%80%82
Docker特定环境变量(如POSTGRES_DB、POSTGRES_USER、POSTGRES_PASSWORD)仅在容器使用空数据目录启动时生效。容器启动时,任何预先存在的数据库将保持不变。
如需重新初始化或更改设置,请先删除或重新创建卷。
libpq环境变量请注意,Docker环境变量与https://www.postgresql.org/docs/current/libpq-envars.html%E4%BD%BF%E7%94%A8%E7%9A%84%E5%8F%98%E9%87%8F**%E4%B8%8D%E5%90%8C**%E3%80%82%E5%90%8E%E8%80%85%E5%8C%85%E6%8B%AC%60PGDATABASE%60%E3%80%81%60PGUSER%60%E3%80%81%60PGPASSWORD%60%E7%AD%89%E5%AE%A2%E6%88%B7%E7%AB%AF%E5%B7%A5%E5%85%B7%E4%BD%BF%E7%94%A8%E7%9A%84%E5%8F%98%E9%87%8F%E3%80%82
故障排除可能具有挑战性。需注意docker-postgis是官方Docker PostgreSQL仓库的扩展,因此遇到问题时,建议先测试是否可使用https://hub.docker.com/_/postgres%E5%A4%8D%E7%8E%B0%E3%80%82%E8%8B%A5%E5%8F%AF%E5%A4%8D%E7%8E%B0%EF%BC%8C%E5%BB%BA%E8%AE%AE%E5%9F%BA%E4%BA%8E%E6%AD%A4%E6%90%9C%E7%B4%A2%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E3%80%82%E6%8E%A8%E8%8D%90%E4%BB%A5%E4%B8%8B%E8%B5%84%E6%BA%90%EF%BC%9A
若问题与PostGIS相关:
若无postgres docker使用经验,建议阅读:
在云环境中,默认设置下这些镜像可能存在风险,若端口开放,极易遭受加密货币挖矿程序感染(https://github.com/docker-library/postgres/issues/770#issuecomment-704460980%EF%BC%89%E3%80%82
-p 5432:5432而非-p 127.0.0.1:5432:5432)将可从外部访问。即使配置UFW阻止该端口,Docker也会管理自己的iptables规则(https://docs.docker.com/network/iptables/%EF%BC%89%E3%80%82每个postgis/postgis:18-*镜像都包含io_uring异步I/O功能。但部分容器运行时(如https://github.com/containerd/containerd/issues/9048%EF%BC%89%E5%9B%A0**%E5%AE%89%E5%85%A8%E8%80%83%E8%99%91**%E6%9B%BE**%E7%A6%81%E7%94%A8io_uring%E6%94%AF%E6%8C%81**%E3%80%82%E5%A6%82%E9%9C%80%E8%AF%95%E7%94%A8%E6%AD%A4%E5%8A%9F%E8%83%BD%EF%BC%8C%E8%AF%B7**%E8%87%AA%E8%A1%8C%E6%89%BF%E6%8B%85%E9%A3%8E%E9%99%A9**%EF%BC%8C%E5%B9%B6%E7%A1%AE%E4%BF%9D%E5%9C%A8https://docs.docker.com/engine/security/seccomp/%E4%B8%AD%E6%98%BE%E5%BC%8F%E5%90%AF%E7%94%A8io_uring%E3%80%82
-c ssl=on -c ssl_cert_file=/var/lib/postgresql/server.crt -c ssl_key_file=/var/lib/postgresql/server.keypostgres Docker镜像的潜在安全问题。若安全扫描器报告漏洞(CVE),请查看[Docker Library FAQ您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务