
https://github.com/postgis/docker-postgis/workflows/Docker%20PostGIS%20CI/badge.svg](https://github.com/postgis/docker-postgis/actions) :
默认VOLUME路径已变更为/var/lib/postgresql
postgis/postgis镜像提供用于运行已安装PostGIS扩展的Postgres的标签。该镜像基于官方https://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%8CDocker%E7%BD%91%E7%BB%9C%E6%96%87%E6%A1%A3%E3%80%82
创建和使用空间数据库的更多选项,请参阅PostGIS文档。
由于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环境变量与libpq — C库使用的变量不同。后者包括PGDATABASE、PGUSER、PGPASSWORD等客户端工具使用的变量。
故障排除可能具有挑战性。需注意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规则(详见)。每个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%A8seccomp%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%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.key-p 127.0.0.1:5432:5432postgres Docker镜像的潜在安全问题。若安全扫描器报告漏洞(CVE),请查看[Docker Library FAQ您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
docker search 限制
站内搜不到镜像
离线 save/load
插件要用 plugin install
WSL 拉取慢
安全与 digest
新手拉取配置
镜像合规机制
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
域名连通性排查
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务