1. Images & Charts
  2. postgis

Echo is acquiring Minimus. See the announcementfor more details.

postgis

postgis

Data
Updated yesterday

Postgis Overview

Secure your stack with a hardened PostGIS image freshly-built by Minimus. Minimus images always include the most up-to-date package version for all packages and dependencies contained in the image.


PostGIS extends a Postgres database with support for geographic and spatial data, so applications can store locations, boundaries, and routes alongside their regular data and query them directly in SQL — finding what falls within a radius, what shapes overlap, or how far apart two points are — without exporting data to a separate GIS system. This makes it a common choice for mapping, logistics, geofencing, and any other workload that needs to reason about location. Deploy Postgres with TLS enabled using our guide.


Try It Out

Take the Minimus PostGIS image for a test run. The following command will set the superuser password to Minimus! but you can set any password you want:

docker run --rm -d --name my-minimus-postgis \
-e POSTGRES_PASSWORD=Minimus! \
reg.mini.dev/postgis

The environment variable POSTGRES_PASSWORD is required, as it sets the password. Note that this test container will not persist the data so as soon as the container stops, the data will be lost.

Ready to mount a persistent data volume?

In your host's project directory, mount a new data directory to the default data directory in the container /var/lib/postgresql/data. To do this run the following command:

docker run --rm -d --name my-minimus-postgis \
    -e POSTGRES_PASSWORD=Minimus! \
    -v $(pwd)/data:/var/lib/postgresql/data \
    reg.mini.dev/postgis

Note: the data directory will consequently be owned by UID 10001.

Postgres will now automatically store its data in the target directory on your host so it won't be lost when you restart the container.

Open an interactive shell in your running container.

docker exec -it my-minimus-postgis sh

Switch from the root user to the postgres user and access the shell:

su postgres
psql

Ready to enable PostGIS and store spatial data?

For our example, we will pass a command to create a database:

CREATE DATABASE minimus_test;

Connect to the database you just created:

\c minimus_test

Enable the PostGIS extension in the database:

CREATE EXTENSION postgis;

Confirm the extension is active and check the installed version:

SELECT postgis_full_version();

Postgres will print the installed PostGIS build details. For example:

minimus_test=# SELECT postgis_full_version();
                                                            postgis_full_version
------------------------------------------------------------------------------------------------------------------------------------------
 POSTGIS="3.5.0" GEOS="3.12.1" PROJ="9.3.1" GDAL="3.8.4" LIBXML="2.12.4" LIBJSON="0.17" LIBPROTOBUF="1.4.1" WAGYU="0.5.0" (core procs from "3.5.0" need upgrade)
(1 row)

Create a table with a spatial column:

CREATE TABLE locations (
    id SERIAL PRIMARY KEY,
    name VARCHAR(100),
    geom GEOMETRY(Point, 4326)
);

Insert a couple of points, given as longitude/latitude coordinates:

INSERT INTO locations (name, geom) VALUES ('Warehouse A', ST_SetSRID(ST_MakePoint(-122.4194, 37.7749), 4326));
INSERT INTO locations (name, geom) VALUES ('Warehouse B', ST_SetSRID(ST_MakePoint(-73.9857, 40.7484), 4326));

Query the distance between the two points, in meters:

SELECT ST_Distance(a.geom::geography, b.geom::geography) AS meters
FROM locations a, locations b
WHERE a.name = 'Warehouse A' AND b.name = 'Warehouse B';

You should see a result such as:

minimus_test=# SELECT ST_Distance(a.geom::geography, b.geom::geography) AS meters
FROM locations a, locations b
WHERE a.name = 'Warehouse A' AND b.name = 'Warehouse B';
      meters      
-------------------
 4129088.297664509
(1 row)

Technical Considerations

The PostGIS image provided by Minimus is a slim, security-hardened alternative to the public image from Docker Hub. The images are largely interchangeable, with a few differences as noted below.

Postgis built by Minimus:

PLACEHOLDER — VERIFY: the public postgis/postgis image is built directly from the public postgres image plus an initdb script, with no other changes, so items 1–5 below are carried over from the Minimus Postgres overview on that basis. They have not been individually confirmed against the actual built postgis image (default user, entrypoint path, volume, working directory) — verify against the image itself, e.g. via docker inspect, before publishing.

  1. The Postgres process runs as nonroot as user 10001 (postgres). However, the entrypoint script runs as root for permissions to set up the environment, hence the compliance report shows that the image runs as root.
  2. Listens by default on port 5432/TCP without exposing it. The public image listens on and exposes port 5432/TCP by default.
  3. The entrypoint script is located at /usr/bin/docker-entrypoint.sh. The public image entrypoint script is directly under the root directory.
  4. The image does not have a default volume. The public image defaults to /var/lib/postgresql/data.
  5. The default working directory is /home/postgres. The public image working directory defaults to the root directory.
  6. Drill down on the version specification tab to see the default user, listening ports, entrypoint, volumes, environment variables, etc.

The Payoff

A hardened, minimal image that will remain more secure for the long run and accrue vulnerabilities at a slower rate.


Terms & Info

Trademark

This catalog is published by Minimus. All product names, logos, and marks, other than those belonging to Minimus, shown are owned by their respective rights holders and appear here only to identify the open source software each image contains. Minimus claims no ownership of those marks and implies no affiliation with, endorsement by, certification by, or sponsorship by any rights holder.

Disclaimer

Images are provided "as-is" without warranty of any kind. "Hardened" refers to the security configuration applied at the time of build and does not constitute a guarantee of ongoing security or absence of vulnerabilities. The free tier is provided without support, SLA, or guaranteed patching timelines. Security updates may be applied to paid subscriptions before or instead of free tier images. By pulling or using any image you agree to our Terms of Use.