I’m starting a keycloak
server and want to let the server import a default realm (as for the start). But even this does not work:
/tmp/example-realm.json
:
{
"realm": "springboot-quickstart",
"enabled": true,
"sslRequired": "external",
"registrationAllowed": true,
"requiredCredentials": [ "password" ],
"clients": [
{
"clientId": "service-springboot",
"enabled": true,
"bearerOnly": true,
"protocol": "openid-connect"
}
]
}
Start with:
docker run -p 8180:8080
-e KEYCLOAK_ADMIN=admin
-e KEYCLOAK_ADMIN_PASSWORD=admin
-e KEYCLOAK_IMPORT=/tmp/example-realm.json
-v /tmp/example-realm.json:/tmp/example-realm.json
quay.io/keycloak/keycloak:17.0.0 start-dev
Result: only the master
realm exists, but my imported realm is missing.
Instead, when I go to the admin page of keycloak and import that file manually, the client "springboot-quickstart" is imported into my master
realm successfully. So the json file should be fine in general.
So why doesn’t this work on initial startup?
3
Answers
I could fix it as follows:
-e JAVA_OPTS="-Dkeycloak.import=/tmp/example-realm.json"
But still I'd like to know why
-e KEYCLOAK_IMPORT
does not work.It’s a bug in 17.0.0 it seems like, but will be fixed in 17.0.1.
See this issue
Using keycloak 18.0.1 with the
--import-realm
flag I was able to drop my json into the data/import folder and it seems to work: