I am working with GeoServer and I'm interested in storing its configuration data outside of the default file-based catalog. Specifically, I want to manage and persist configurations like:
Workspaces: Workspace names and settings. Stores: Data store connections and details. Layers: Layer definitions, styles, and associated data stores. Styles: SLD styles and style configurations. Groups: User groups and roles (if relevant to external configuration). Services Configuration: Settings for WMS, WFS, WCS, etc.
I want to use kartoza/docker-geoserver - and in its docs it says- The image uses kartoza/postgis as a database backend. You can use any other PostgreSQL image but adjust the environment variables accordingly.
postgis -
geoserver -
Will it be possible, i need docker-compose file run so that it will save all the detail in postgres not in file based database. Thank you
here is my docker file for postgis
version: "3.7"
services:
db:
image: kartoza/postgis:latest # Using Kartoza PostGIS image
environment:
POSTGRES_USER: geoserver # Username for PostgreSQL (consistent for both DBs)
POSTGRES_PASSWORD: geoserver # Password for PostgreSQL (consistent for both DBs)
POSTGRES_DB: geoserver_data # Database for your spatial data (e.g., layers)
ports:
- "5432:5432" # Optional: Expose PostgreSQL port for external access (e.g., psql)
volumes:
- db_data:/var/lib/postgresql/data # Persist PostgreSQL data using a named volume
volumes:
db_data: # Named volume for PostgreSQL data persistence
docker file for geoserver
version: "3.7"
services:
geoserver:
image: kartoza/geoserver:latest # Using Kartoza Geoserver image
ports:
- "8080:8080" # Expose Geoserver web interface on port 8080
environment:
# --- JDBC Config Extension Settings for PostgreSQL Catalog ---
GEOSERVER_CATALOG_DB_TYPE: postgresql # Specify PostgreSQL for catalog
GEOSERVER_CATALOG_DB_HOST: db # 'db' service name resolves to PostgreSQL container
GEOSERVER_CATALOG_DB_PORT: 5432 # PostgreSQL default port
GEOSERVER_CATALOG_DB_DATABASE: geoserver_data # Database for Geoserver's configuration catalog (typo in original request corrected to 'geoserver_catalog' if intended to be different from data DB, but currently using data DB name)
GEOSERVER_CATALOG_DB_USER: geoserver # Use the same PostgreSQL user
GEOSERVER_CATALOG_DB_PASS: geoserver # Use the same PostgreSQL password
# --- Optional: Configure default database for data sources (e.g., PostGIS layers) ---
# GEOSERVER_POSTGRES_DB: geoserver_data # Uncomment to set 'geoserver_data' as default DB
I am working with GeoServer and I'm interested in storing its configuration data outside of the default file-based catalog. Specifically, I want to manage and persist configurations like:
Workspaces: Workspace names and settings. Stores: Data store connections and details. Layers: Layer definitions, styles, and associated data stores. Styles: SLD styles and style configurations. Groups: User groups and roles (if relevant to external configuration). Services Configuration: Settings for WMS, WFS, WCS, etc.
I want to use kartoza/docker-geoserver - https://github/kartoza/docker-geoserver and in its docs it says- The image uses kartoza/postgis as a database backend. You can use any other PostgreSQL image but adjust the environment variables accordingly.
postgis - https://github/kartoza/docker-postgis
geoserver - https://github/kartoza/docker-geoserver
Will it be possible, i need docker-compose file run so that it will save all the detail in postgres not in file based database. Thank you
here is my docker file for postgis
version: "3.7"
services:
db:
image: kartoza/postgis:latest # Using Kartoza PostGIS image
environment:
POSTGRES_USER: geoserver # Username for PostgreSQL (consistent for both DBs)
POSTGRES_PASSWORD: geoserver # Password for PostgreSQL (consistent for both DBs)
POSTGRES_DB: geoserver_data # Database for your spatial data (e.g., layers)
ports:
- "5432:5432" # Optional: Expose PostgreSQL port for external access (e.g., psql)
volumes:
- db_data:/var/lib/postgresql/data # Persist PostgreSQL data using a named volume
volumes:
db_data: # Named volume for PostgreSQL data persistence
docker file for geoserver
version: "3.7"
services:
geoserver:
image: kartoza/geoserver:latest # Using Kartoza Geoserver image
ports:
- "8080:8080" # Expose Geoserver web interface on port 8080
environment:
# --- JDBC Config Extension Settings for PostgreSQL Catalog ---
GEOSERVER_CATALOG_DB_TYPE: postgresql # Specify PostgreSQL for catalog
GEOSERVER_CATALOG_DB_HOST: db # 'db' service name resolves to PostgreSQL container
GEOSERVER_CATALOG_DB_PORT: 5432 # PostgreSQL default port
GEOSERVER_CATALOG_DB_DATABASE: geoserver_data # Database for Geoserver's configuration catalog (typo in original request corrected to 'geoserver_catalog' if intended to be different from data DB, but currently using data DB name)
GEOSERVER_CATALOG_DB_USER: geoserver # Use the same PostgreSQL user
GEOSERVER_CATALOG_DB_PASS: geoserver # Use the same PostgreSQL password
# --- Optional: Configure default database for data sources (e.g., PostGIS layers) ---
# GEOSERVER_POSTGRES_DB: geoserver_data # Uncomment to set 'geoserver_data' as default DB
Share
Improve this question
edited Mar 13 at 10:52
Atul Singh
asked Mar 13 at 10:26
Atul SinghAtul Singh
234 bronze badges
3
- Was there some error when you followed the instructions? There doesn't seem to be a question here. – Richard Huxton Commented Mar 13 at 10:50
- I have updated the question, i am not able to login it says username and password is incorrect @RichardHuxton, can you verify it, i mean is it possible to chnge backend database change? – Atul Singh Commented Mar 13 at 10:54
- I am not familiar with these particular containers you are using, and can't give specific advice. But the first thing to test is to see if you can connect directly to the database container with that username + password. If you don't know how to do that, you probably need to take a step back and learn a little about both postgresql and docker before trying again. – Richard Huxton Commented Mar 13 at 11:02
2 Answers
Reset to default 1This is working for me
geoserver:
image: kartoza/geoserver:2.26.1
container_name: geoserver
environment:
DB_BACKEND: POSTGRES
HOST: postgis
POSTGRES_PORT: 5432
POSTGRES_DB: geoserver_backend
POSTGRES_USER: postgres
POSTGRES_PASS: root
SSL_MODE: allow
POSTGRES_SCHEMA: public
DISK_QUOTA_SIZE: 5
COMMUNITY_EXTENSIONS: jdbcconfig-plugin,jdbcstore-plugin
GEOSERVER_ADMIN_PASSWORD: geoserver
GEOSERVER_ADMIN_USER: admin
SAMPLE_DATA: TRUE
USE_DEFAULT_CREDENTIALS: TRUE
volumes:
- geoserver_data:/opt/geoserver/data_dir
- ./web-conf.xml:/usr/local/tomcat/conf/web.xml
- ./web-inner.xml:/usr/local/tomcat/webapps/geoserver/WEB-INF/web.xml
ports:
- "8080:8080"
You need to add the JDBC Configuration extension to be able to store configuration in a database. As far as I can see the Kartoza docker image just allows you to store vector data in the PostGIS database. If you just want to make the configuration changes that you make more permanent then you need to change GEOSERVER_DATA_DIR=/opt/geoserver/data_dir
to point to somewhere that you control.