Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keycloak docker container fails to import realm from volume

I want to run keycloak container with below docker compose file.

version: '2.1'

services:
  # keycloak
  keycloak:
    container_name: keycloak
    image: jboss/keycloak:latest
    restart: always
    ports:
      - 8080:8080
    volumes:
      - C:\logs\keycloak:/usr/app/logs
      - C:\settings:/etc/settings
    environment:
      - KEYCLOAK_USER=admin
      - KEYCLOAK_PASSWORD=admin
      - KEYCLOAK_IMPORT=/etc/settings/realm.json

Everything except realm import works fine in this case. This is shortcut of the error thrown during container run:

Caused by: java.lang.RuntimeException: RESTEASY003325: Failed to construct public org.keycloak.services.resources.KeycloakApplication(javax.servlet.ServletContext,org.jboss.resteasy.core.Dispatcher) Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: /etc/settings/realm.json (Is a directory) Caused by: java.io.FileNotFoundException: /etc/settings/realm.json (Is a directory)"}`

I am sure the file exists in this location. I have checked several different configurations for import e.g. specyfing imported file: C:\settings\realm.json:/etc/settings/realm.json but the result is the same. Have you got any ideas how the proper configuration should look like?

like image 994
Zebedeusz Avatar asked Nov 07 '22 00:11

Zebedeusz


1 Answers

I had the same issue. It was caused by the fact that I was attempting to mount a volume using a relative path. I resolved it by replacing all relative paths with absolute paths.

like image 185
no_rayna Avatar answered Nov 14 '22 22:11

no_rayna