Keycloak 17 - KEYCLOAK_IMPORT - Docker Compose - Not Working

Hello,

I am unable to trigger KC to import a realm using the KEYCLOAK_IMPORT environment variable when using Docker / Docker Compose.

I have previously logged into the KC admin tool, created a realm, and successfully exported the realm’s JSON. I can go into KC using the admin tool, and import the JSON successfully via the CREATE REALM import option in the KC admin tool.

I am unable to import / create this realm, from the previously exported JSON file, when I start KC using Docker / Docker Compose. I am using keycloak:latest and the KEYCLOAK_IMPORT environment variable.

DockerFile (incomplete - shows copying realm JSON to container

COPY /config/instrument_interface_realm.json /tmp/instrument_interface_realm.json

Docker Compose:

build: keycloak
environment:
      - KEYCLOAK_ADMIN=admin
      - KEYCLOAK_ADMIN_PASSWORD=xxxxxxxxxxxxxxx
      - KC_ENV
      - KEYCLOAK_IMPORT=/tmp/instrument_interface_realm.json
    ports:
      - "8081:8080"

Docker Startup Command:

/opt/keycloak/bin/kc.sh start-dev

Additional Info:

  • The file is successfully copied to the container and exists at /tmp/instrument_interface_realm.json.
  • I can shell into the running container and see that the KEYCLOAK_IMPORT environment is properly set.

The KC container starts up successfully but the realm is never imported. There is nothing in the logs that indicates KC even attempts an import.

I am unable to locate any other information that I might be missing. Does anyone have any insights? Thanks in advance!