This page describes how to manually add the PostGIS
extension to an existing AlloyDB Omni
installation. The PostGIS extension enables storing, indexing, and querying
geospatial data.
You can install PostGIS using either of the following methods:
Use Debian options in the Docker or Podman CLI. Docker relies on a daemon
and requires root privileges for most operations, while Podman is daemonless
and rootless.
Use Red Hat Universal Base Images (UBI). UBI container base operating system
images are built from parts of Red Hat Enterprise Linux (RHEL).
To add the PostGIS extension to your AlloyDB Omni installation,
follow these steps:
Find your installed AlloyDB Omni version labels:
Docker
dockerrun--rm-itgoogle/alloydbomnicatVERSION.txt
Podman
podmanrun--rm-itgoogle/alloydbomnicatVERSION.txt
The output is similar to the following:
AlloyDB Omni version: 16.8.0
Take note of the AlloyDB Omni version number because you need it in the next step.
Set the OMNI_VERSION environment variable:
OMNI_VERSION=VERSION
Replace VERSION with the complete database server version from the previous step, for example, 16.8.0.
Build a custom Docker image that includes the PostGIS extension:
mkdir~/alloydb-omni-postgis
cd~/alloydb-omni-postgis
sudodnfinstall-ysubscription-manager
sudosubscription-managerregister--usernameEMAIL--passwordPASSWORD--auto-attach
sudomkdir-pentitlementrhsm-confrhsm-ca
sudocp-r/etc/pki/entitlement/*entitlement/
sudocp-r/etc/rhsm/rhsm.confrhsm-conf/
sudocp-r/etc/rhsm/ca/*rhsm-ca/
cat<<EOF > Dockerfile
FROMgoogle/alloydbomni:16.8.0-ubi
COPY./entitlement/etc/pki/entitlement
COPY./rhsm-conf/etc/rhsm
COPY./rhsm-ca/etc/rhsm/ca
RUNarch=$(uname-m) && \subscription-managerrepos--enablecodeready-builder-for-rhel-9-${arch}-rpms && \dnfinstall-y\https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-${arch}/pgdg-redhat-repo-latest.noarch.rpm && \dnfinstall-ypostgresql16-serverpostgis34_16 && \dnfcleanall
# On RHEL-based systems, PostgreSQL extensions like Orafce and PostGIS are typically installed in /usr/pgsql-16/share/extension and /usr/pgsql-16/lib.# This step creates symbolic links to those files in the paths expected by AlloyDB Omni,# which lets AlloyDB Omni locate extension control files and shared libraries without duplicating data.RUNforfilein/usr/pgsql-16/share/extension/*;do\target="/usr/lib/postgresql/16/share/extension/$(realpath-m--relative-to=/usr/pgsql-16/share/extension/"$file")";\if[!-e"$target"];then\ln-s"$file""$target"||(echo"Failed to link \"$file\" to \"$target\", exiting." && exit1);\else\echo"$target already exists";\fi;\done && \forfilein/usr/pgsql-16/lib/*;do\target="/usr/lib/postgresql/16/lib/$(realpath-m--relative-to=/usr/pgsql-16/lib/"$file")";\if[!-e"$target"];then\ln-s"$file""$target"||(echo"Failed to link \"$file\" to \"$target\", exiting." && exit1);\else\echo"$target already exists";\fi;\done
EOF
Create a new container with AlloyDB Omni named my-omni-postgis:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-25 UTC."],[[["\u003cp\u003eAlloyDB Omni does not inherently include the PostGIS extension, but it can be added manually to support geospatial data.\u003c/p\u003e\n"],["\u003cp\u003eTo add PostGIS, you must first determine your current AlloyDB Omni version by using \u003ccode\u003edocker\u003c/code\u003e or \u003ccode\u003epodman\u003c/code\u003e to run the command \u003ccode\u003ecat VERSION.txt\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eAfter determining your AlloyDB Omni version, you need to set the \u003ccode\u003eOMNI_VERSION\u003c/code\u003e environment variable with the version number and then create a new Docker container that includes PostGIS.\u003c/p\u003e\n"],["\u003cp\u003eOnce you have created a new container, name it \u003ccode\u003emy-omni-postgis\u003c/code\u003e and start it, you can then connect to the database and enable PostGIS with the command \u003ccode\u003eCREATE EXTENSION IF NOT EXISTS POSTGIS;\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Install PostGIS for AlloyDB Omni\n\nSelect a documentation version: Current (16.8.0)keyboard_arrow_down\n\n- [Current (16.8.0)](/alloydb/omni/current/docs/install-postgis)\n- [16.8.0](/alloydb/omni/16.8.0/docs/install-postgis)\n- [16.3.0](/alloydb/omni/16.3.0/docs/install-postgis)\n- [15.12.0](/alloydb/omni/15.12.0/docs/install-postgis)\n- [15.7.1](/alloydb/omni/15.7.1/docs/install-postgis)\n- [15.7.0](/alloydb/omni/15.7.0/docs/install-postgis)\n- [15.5.5](/alloydb/omni/15.5.5/docs/install-postgis)\n- [15.5.4](/alloydb/omni/15.5.4/docs/install-postgis)\n- [15.5.2](/alloydb/omni/15.5.2/docs/install-postgis)\n\n\u003cbr /\u003e\n\nDebian UBI\n\n\u003cbr /\u003e\n\nThis page describes how to manually add the [PostGIS\nextension](http://www.postgis.net/) to an existing AlloyDB Omni\ninstallation. The PostGIS extension enables storing, indexing, and querying\ngeospatial data.\n\nYou can install PostGIS using either of the following methods:\n\n- Use Debian options in the Docker or Podman CLI. Docker relies on a daemon and requires root privileges for most operations, while Podman is daemonless and rootless.\n- Use Red Hat Universal Base Images (UBI). UBI container base operating system images are built from parts of Red Hat Enterprise Linux (RHEL).\n\nBefore you begin\n----------------\n\n[Install AlloyDB Omni](/alloydb/omni/current/docs/install) on your system.\n\nAdd PostGIS to your AlloyDB Omni installation\n---------------------------------------------\n\nTo add the PostGIS extension to your AlloyDB Omni installation,\nfollow these steps:\n\n1. Find your installed AlloyDB Omni version labels:\n\n ### Docker\n\n docker run --rm -it google/alloydbomni cat VERSION.txt\n\n ### Podman\n\n podman run --rm -it google/alloydbomni cat VERSION.txt\n\n The output is similar to the following: \n\n AlloyDB Omni version: 16.8.0\n\n Take note of the AlloyDB Omni version number because you need it in the next step.\n2. Set the \u003cvar translate=\"no\"\u003eOMNI_VERSION\u003c/var\u003e environment variable:\n\n OMNI_VERSION=\u003cvar translate=\"no\"\u003eVERSION\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eVERSION\u003c/var\u003e with the complete database server version from the previous step, for example, `16.8.0`.\n3. Build a custom Docker image that includes the PostGIS extension:\n\n mkdir ~/alloydb-omni-postgis\n\n cd ~/alloydb-omni-postgis\n\n sudo dnf install -y subscription-manager\n\n sudo subscription-manager register --username \u003cvar translate=\"no\"\u003eEMAIL\u003c/var\u003e --password \u003cvar translate=\"no\"\u003ePASSWORD\u003c/var\u003e --auto-attach\n\n sudo mkdir -p entitlement rhsm-conf rhsm-ca\n sudo cp -r /etc/pki/entitlement/* entitlement/\n sudo cp -r /etc/rhsm/rhsm.conf rhsm-conf/\n sudo cp -r /etc/rhsm/ca/* rhsm-ca/\n\n cat \u003c\u003cEOF \u003e Dockerfile\n FROM google/alloydbomni:16.8.0-ubi\n COPY ./entitlement /etc/pki/entitlement\n COPY ./rhsm-conf /etc/rhsm\n COPY ./rhsm-ca /etc/rhsm/ca\n RUN arch=$(uname -m) && \\\n subscription-manager repos --enable codeready-builder-for-rhel-9-${arch}-rpms && \\\n dnf install -y \\\n https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-${arch}/pgdg-redhat-repo-latest.noarch.rpm && \\\n dnf install -y postgresql16-server postgis34_16 && \\\n dnf clean all\n # On RHEL-based systems, PostgreSQL extensions like Orafce and PostGIS are typically installed in /usr/pgsql-16/share/extension and /usr/pgsql-16/lib.\n # This step creates symbolic links to those files in the paths expected by AlloyDB Omni,\n # which lets AlloyDB Omni locate extension control files and shared libraries without duplicating data.\n RUN for file in /usr/pgsql-16/share/extension/*; do \\\n target=\"/usr/lib/postgresql/16/share/extension/$(realpath -m --relative-to=/usr/pgsql-16/share/extension/ \"$file\")\"; \\\n if [ ! -e \"$target\" ]; then \\\n ln -s \"$file\" \"$target\" || (echo \"Failed to link \\\"$file\\\" to \\\"$target\\\", exiting.\" && exit 1); \\\n else \\\n echo \"$target already exists\"; \\\n fi; \\\n done && \\\n for file in /usr/pgsql-16/lib/*; do \\\n target=\"/usr/lib/postgresql/16/lib/$(realpath -m --relative-to=/usr/pgsql-16/lib/ \"$file\")\"; \\\n if [ ! -e \"$target\" ]; then \\\n ln -s \"$file\" \"$target\" || (echo \"Failed to link \\\"$file\\\" to \\\"$target\\\", exiting.\" && exit 1); \\\n else \\\n echo \"$target already exists\"; \\\n fi; \\\n done\n EOF\n\n \u003cbr /\u003e\n\n4. Create a new container with AlloyDB Omni named `my-omni-postgis`:\n\n ### Docker\n\n docker build -t google/alloydbomni-with-postgis:latest\n docker run --name my-omni-postgis -e POSTGRES_PASSWORD=\u003cvar translate=\"no\"\u003eNEW_PASSWORD\u003c/var\u003e -d google/alloydbomni-with-postgis:\u003cvar translate=\"no\"\u003eOMNI_VERSION\u003c/var\u003e\n\n ### Podman\n\n podman run --name my-omni-postgis -e POSTGRES_PASSWORD=\u003cvar translate=\"no\"\u003eNEW_PASSWORD\u003c/var\u003e -d google/alloydbomni-with-postgis:\u003cvar translate=\"no\"\u003eOMNI_VERSION\u003c/var\u003e\n\n5. Connect to your database with the PostGIS extension:\n\n docker exec -it my-omni-postgis psql -h localhost -U postgres\n\n6. Enable PostGIS:\n\n CREATE EXTENSION IF NOT EXISTS POSTGIS;\n SELECT postgis_full_version();\n\n The output looks similar to the following: \n\n postgres=# SELECT postgis_full_version();\n postgis_full_version\n --------------------------------------------------------------------------------------------------------------------------------\n POSTGIS=\"3.3.2 4975da8\" [EXTENSION] PGSQL=\"150\" GEOS=\"3.11.1-CAPI-1.17.1\" PROJ=\"9.1.1\" LIBXML=\"2.9.14\" LIBJSON=\"0.16\" LIBPROTOBUF=\"1.4.1\" WAGYU=\"0.5.0 (Internal)\"\n (1 row)"]]