The GeoServer Docker Container changes the ownership of the mounted data and exts directories to uid 1099.
Inspection shows that this is the user Tomcat.
This makes redeployments fail because of this changed ownership:
TASK [PRE-TASK - Clone or Update Git Repo] *************************************
fatal: [OGCAPIP]: FAILED! => {"changed": false, "cmd": "/usr/bin/git reset --hard HEAD", "msg": "error: unable to unlink old 'services/geoserver/data/global.xml': Permission denied\nerror: unable to unlink old 'services/geoserver/data/workspaces/geonovum/schiedam/datastore.xml': Permission denied\nfatal: Could not reset index file to revision 'HEAD'.", "rc": 128, "stderr": "error: unable to unlink old 'services/geoserver/data/global.xml': Permission denied\nerror: unable to unlink old 'services/geoserver/data/workspaces/geonovum/schiedam/datastore.xml': Permission denied\nfatal: Could not reset index file to revision 'HEAD'.\n", "stderr_lines": ["error: unable to unlink old 'services/geoserver/data/global.xml': Permission denied", "error: unable to unlink old 'services/geoserver/data/workspaces/geonovum/schiedam/datastore.xml': Permission denied", "fatal: Could not reset index file to revision 'HEAD'."], "stdout": "", "stdout_lines": []}
Solution is to change the ownership back. This script, bit of a hack but will fix this:
# Author: Just van den Broecke
HOST_UID=`id -u`
HOST_FOLDERS="$(pwd)/data $(pwd)/exts"
for FOLDERS in ${HOST_FOLDERS}
do
echo "Fixing folder ${FOLDER}"
docker run --rm -it \
--entrypoint /bin/sh \
-e HOST_UID=${HOST_UID} \
-v ${FOLDER}:/tmp \
alpine:latest \
-c 'chown -R ${HOST_UID}:${HOST_UID} /tmp/'
done
The GeoServer Docker Container changes the ownership of the mounted
data
andexts
directories to uid 1099. Inspection shows that this is the user Tomcat.This makes redeployments fail because of this changed ownership:
Solution is to change the ownership back. This script, bit of a hack but will fix this:
Inspiration: https://stackoverflow.com/questions/26500270/understanding-user-file-ownership-in-docker-how-to-avoid-changing-permissions-o/26514736#26514736