I am currently creating a Docker Container to Pre-Seed GeoWebCache caches. The idea is to spin up the Docker Container(s) to create the caches when there are new Orthophotos and kill them when done seeding --> see.

The idea is to store the caches in Azure Blob Storages using the Azure Blob Storage Plugin and serve the caches via an "main" Geoserver Instances on an extra VM. The problem I am facing is that the internal Geoserver creates an specific ID like LayerInfoImpl--53dcac5c:17b1025e89f:-7ff8 which is then used as the root container for the Blobs in Azure, which mismatches with the ID on my "main" Geoserver Instance (looks like the ID is randomly created). Unfortunately I couldn't find a way to explicitly set this ID so my Docker Container and the "main" Geoserver Instance use the same ID and a mapping can be done. Is there a way using the REST API or some script to set / change the id? Preferably like topp:states.

I have already tried the PUT and POST endpoints. Setting / Updating the id in the payload like:


Unfortunately this doesn't work.

  • 1
    The answer to your previous question clearly said not to do it this way (because of the problem you have found) - you want one GWC and multiple GeoServers to do the rendering for it,
    – Ian Turton
    Aug 4 at 8:25
  • Oh I see, didn't get that. Well than I have to change my setup. Thank you for pointing that out!
    – öbl
    Aug 4 at 8:35

I was able to find a workaround:

  1. Prerequirements are that the Workspace, Mosaic Storage and Layer on the main Geoserver Instance already exists and that an Azure Blob Store is configured as the Store for the GWC Layer.
  2. In the Docker Container I create the same Workspace, Mosaic Storage, Layer and Azure Blob Store (using curl and the Geoserver Rest API).
  3. As mentioned the Layer ID is not the same (on the Main Geoserver and the one running in the Docker Container), so I had to query the ID from the Main Geoserver Instance using LAYER_MAIN_ID=$(curl --location --request GET ''"$MAIN_GEOSERVER_URL"'/geoserver/gwc/rest/layers/'"$PROJECT_ID"':'"$PROJECT_ID"'.json' --header 'Content-Type: application/json' --header 'Authorization: Basic '$MAIN_GEOSERVER_BASIC_PW'' | jq -r '.GeoServerLayer.id')
  4. .. and query the Layer ID in the Docker Container: LAYER_DOCKER_ID=$(curl --location --request GET ''"$GEOSERVER_LOCALHOST"':8080/geoserver/gwc/rest/layers/'"$PROJECT_ID"':'"$PROJECT_ID"'.json' --header 'Content-Type: application/json' --header 'Authorization: Basic '$GEOSERVER_BASIC_PW'' | jq -r '.GeoServerLayer.id')
  5. Afterwards the Layer ID had to be replaced in multiple locations:
  6. in the Layer Definition: find "$GEOSERVER_HOME/data_dir/workspaces/$PROJECT_ID/$PROJECT_ID/$PROJECT_ID/layer.xml" -type f -exec sed -i "s/$LAYER_DOCKER_ID/$LAYER_MAIN_ID/g" {} +
  7. Rename the GWC-Layer Definition File: LAYER_DOCKER_ID_FILENAME=${LAYER_DOCKER_ID//\:/_} LAYER_MAIN_ID_FILENAME=${LAYER_MAIN_ID//\:/_} mv "$GEOSERVER_HOME/data_dir/gwc-layers/$LAYER_DOCKER_ID_FILENAME.xml" "$GEOSERVER_HOME/data_dir/gwc-layers/$LAYER_MAIN_ID_FILENAME.xml"
  8. Change the ID in the GWC-Layer Definition File: find "$GEOSERVER_HOME/data_dir/gwc-layers/$LAYER_MAIN_ID_FILENAME.xml" -type f -exec sed -i "s/$LAYER_DOCKER_ID/$LAYER_MAIN_ID/g" {} +
  9. Afterwards the Config needs to be reloaded: curl --location --request POST ''"$GEOSERVER_LOCALHOST"':8080/geoserver/rest/reload' \ --header 'Authorization: Basic '$GEOSERVER_BASIC_PW''

Last step is to start the seeding process using the API. When the container is done it kills the Docker Container. For a 14GB Orthophoto a 8GB 4CPU Azure Docker Container is running ~ 8 hours. Which costs less than 2€. And the main Geoserver is able to concentrate on the hosting rather the processing of the tiles.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.