kartoza / docker-geoserver

A docker recipe for GeoServer
GNU General Public License v2.0
628 stars 423 forks source link

UID/GID issue with prebuilt image in docker-compose and external volume #564

Closed Hyradus closed 1 year ago

Hyradus commented 1 year ago

What is the bug or the crash?

Hi all, first of all thanks for this amazing repo!

I am trying to integrate geoserver prebuilt image in the following docker-compose:

version: "3.9"
volumes:
  geoserver-data:
    external:
      name: ${GS_DATA_VOL}
services:
   geoserver:
    image: kartoza/geoserver:${GS_VERSION}
    container_name: geoserver
    ports:
      - 8080:8080
    volumes:
      - geoserver-data:${GEOSERVER_DATA_DIR}
    restart: on-failure
    environment:
        - GEOSERVER_DATA_DIR=${GEOSERVER_DATA_DIR}        
        - GEOSERVER_ADMIN_PASSWORD=${GEOSERVER_ADMIN_PASSWORD}
        - GEOSERVER_ADMIN_USER=${GEOSERVER_ADMIN_USER}
        - INITIAL_MEMORY=${INITIAL_MEMORY}
        - MAXIMUM_MEMORY=${MAXIMUM_MEMORY}
        - COMMUNITY_EXTENSIONS=${COMMUNITY_EXTENSIONS}
        - GEOSERVER_UID=${UID}
        - GEOSERVER_GID=${GID}
        - EXISTING_DATA_DIR=true
    healthcheck:
        test: "curl --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null -u #${GEOSERVER_ADMIN_USER}:'${GEOSERVER_ADMIN_PASSWORD}' http://localhost:8080/geoserver/rest/about/version.xml"
        interval: 1m30s
        timeout: 10s
        retries: 3

my .env

GEOSERVER_PORT=8080

GS_DATA_VOL='geoserver-data'
GS_VERSION=2.23.0
GEOSERVER_DATA_DIR=/opt/geoserver/data_dir
GEOSERVER_ADMIN_USER=geouser
GEOSERVER_ADMIN_PASSWORD=testgeo
INITIAL_MEMORY=2G
MAXIMUM_MEMORY=8G
COMMUNITY_EXTENSIONS='cog-plugin,backup-restore-plugin'
STABLE_EXTENSIONS='importer-plugin,netcdf-plugin'
UID=1005
GID=1005

When I execute docker-compose up, it seems to run fine, but I only get a 404 page with geoserver/web folder not found.

Checking the mounted volume, the files are there but the uid/gid are 1000 (root) instead of those specificed in the env.

Manually chowning with the correct uid/gid (after docker-compose down) results with the same 404 page.

Using an internal volume works.

If i run simple docker run with the same env variables:

docker run --name "geoserver" -e GEOSERVER_ADMIN_USER=geouser -e GEOSERVER_ADMIN_PASSWORD=testgeo -e GEOSERVER_UID=1005 -e GEOSERVER_GID=1005 -p 8080:8080 -v /geoserver-data:/opt/geoserver/data_dir --rm -it kartoza/geoserver:2.23.0

everything is working, the uid/gid are correct and I can login, etc.

Then, if I stop this container and execute docker-compose up again, everything is working.

I tried different external volumes (local and network directories), but I get the same results.

So, I think I am missing something, in the docker-compose configuration because with the same env, docker-compose not works while docker run works.

EDIT1

Some additional/summary tests.

Steps to reproduce the issue

Versions

2.23.0

Additional context

I want to use docker-compose with prebuilt images since I am integrating it with other services and I wanted to keep as "standard" as possible

NyakudyaA commented 1 year ago

It works on my instance: image

image

Hyradus commented 1 year ago

Thank for your reply and test!

It is really weird, I think I'll associate this issue with specific NFS behaviour.

I'll close it for now and re-open if I have new findings.