Deploy PostgreSQL with PostGIS on CentOS using Docker Compose
This guide walks through deploying a PostgreSQL instance with the PostGIS extension on a CentOS server using Docker Compose, covering image retrieval, docker‑compose configuration, environment variables, logging settings, container startup, and verification of PostGIS integration.
kartoza/docker-postgis
GitHub repository: https://github.com/kartoza/docker-postgis. The image provides SSL support, a default database named gis, optional streaming and logical replication (disabled by default), the ability to create multiple databases and schemas at container start‑up, automatic GDAL driver registration for raster support, and other features.
Docker Compose deployment
Create a docker-compose.yaml file in a directory on the server and add the following content:
version: "3.8"
services:
postgis:
image: kartoza/postgis:13
container_name: badao_postgis
ports:
- "5432:5432"
volumes:
- ./postgis/data:/var/lib/postgresql
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ALLOW_IP_RANGE: 0.0.0.0/0
logging:
driver: "json-file"
options:
max-size: "500m"
max-file: "3"Create the host directory that the volume maps to: mkdir -p postgis/data The environment variables set the PostgreSQL user, password, and allow connections from any IP address (0.0.0.0/0). Additional environment variables are documented in the repository.
The logging configuration limits each log file to 500 MB and retains up to three files; this section is optional and can be adjusted as needed.
The image tag 13 corresponds to the 13 branch in the GitHub repository.
Pull the image (if network access permits):
docker pull kartoza/postgis:13If pulling fails, a pre‑built image can be downloaded from the URL provided at the end of the article and imported with Docker.
Start the container from the directory containing docker-compose.yaml:
docker compose upIf no errors appear, the container is running. Connect with a database client to verify that the PostGIS extension is available.
Download link for the kartoza/docker-postgis image (version 13)
https://download.csdn.net/download/BADAO_LIUMANG_QIZHI/89765536
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
The Dominant Programmer
Resources and tutorials for programmers' advanced learning journey. Advanced tracks in Java, Python, and C#. Blog: https://blog.csdn.net/badao_liumang_qizhi
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
