Users, roles are lost on geoserver container restart

I am running docker container for Geoserver with base image docker.osgeo.org/geoserver:2.28.0.

I observe that on container restart all users , roles etc created are gone, except amin user. On some investigation, I found that a possible culprit is update_crednetials.sh, as it overwrites, users, roles config with default values.
I want to confirm if my analysis is correct, and if yes, then what is possible workaround for this?

With Docker, it is normal for no data to be stored unless a persistent volume has been configured.

From https://github.com/geoserver/docker:

"

To use an external folder as your geoserver data directory.

docker run -it -p 80:8080 \
  --mount src="/absolute/path/on/host",target=/opt/geoserver_data/,type=bind \
  docker.osgeo.org/geoserver:2.28.2

An empty data directory will be populated on first use. You can easily update GeoServer while using the same data directory."

Actually I am already using external folder as data directory in my docker compsoe:

volumes:
- ./geoserver_data:/opt/geoserver_data

Data is persistent into files like
/opt/geoserver_data/security/usergroup/default/users.xml.

But on restart, it gets overwritten by
/usr/local/tomcat/webapps/geoserver/data/security/usergroup/default/users.xml

I came across thsi on github page:

After the initial setup, it’s recommended to remove the GEOSERVER_ADMIN_USER and GEOSERVER_ADMIN_PASSWORD variable. Otherwise, newly added roles and users may be overwritten by the next time the container is restarted

I think this would help.

I wonder if the script could be updated to only set these values once somehow? Perhaps check the file contents and see if those values are already in use?

1 Like