I am trying to run Keycloak in Docker, but its throwing an error.
Here's the docker file:
FROM jboss/keycloak:4.1.0.Final
WORKDIR /opt/jboss/keycloak
COPY realm-export.json initial_data.json
RUN ./bin/standalone.sh -Dkeycloak.migration.action=import -Dkeycloak.migration.provider=singleFile -Dkeycloak.migration.file=initial_data.json -Dkeycloak.migration.strategy=OVERWRITE_EXISTING
I am using that realm-export.json file because I have some configurations there. And the error that is showing is this one:
12:04:35,033 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 48) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./auth: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./auth: java.lang.RuntimeException: RESTEASY003325: Failed to construct public org.keycloak.services.resources.KeycloakApplication(javax.servlet.ServletContext,org.jboss.resteasy.core.Dispatcher)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:84)
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: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "typedScopes" (class org.keycloak.representations.idm.authorization.ResourceRepresentation), not marked as ignorable (11 known properties: "ownerManagedAccess", "owner", "icon_uri", "attributes", "type", "name", "uri", "displayName", "scopes", "resource_scopes", "_id"])
at [Source: java.io.FileInputStream@6d0b4fbd; line: 690, column: 29] (through reference chain: org.keycloak.representations.idm.RealmRepresentation["clients"]->java.util.ArrayList[2]->org.keycloak.representations.idm.ClientRepresentation["authorizationSettings"]->org.keycloak.representations.idm.authorization.ResourceServerRepresentation["resources"]->java.util.ArrayList[2]->org.keycloak.representations.idm.authorization.ResourceRepresentation["typedScopes"])
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "typedScopes" (class org.keycloak.representations.idm.authorization.ResourceRepresentation), not marked as ignorable (11 known properties: "ownerManagedAccess", "owner", "icon_uri", "attributes", "type", "name", "uri", "displayName", "scopes", "resource_scopes", "_id"])
at [Source: java.io.FileInputStream@6d0b4fbd; line: 690, column: 29] (through reference chain: org.keycloak.representations.idm.RealmRepresentation["clients"]->java.util.ArrayList[2]->org.keycloak.representations.idm.ClientRepresentation["authorizationSettings"]->org.keycloak.representations.idm.authorization.ResourceServerRepresentation["resources"]->java.util.ArrayList[2]->org.keycloak.representations.idm.authorization.ResourceRepresentation["typedScopes"])
While this shows at the end:
12:04:35,121 ERROR [org.jboss.as.server] (ServerService Thread Pool -- 45) WFLYSRV0022: Deploy of deployment "keycloak-server.war" was rolled back with no failure message
ERROR: Service 'keycloak' failed to build: The command '/bin/sh -c ./bin/standalone.sh -Dkeycloak.migration.action=import -Dkeycloak.migration.provider=singleFile -Dkeycloak.migration.file=initial_data.json -Dkeycloak.migration.strategy=OVERWRITE_EXISTING' returned a non-zero code: 1
p.s. When I comment this code in DockerFile
RUN ./bin/standalone.sh -Dkeycloak.migration.action=import -Dkeycloak.migration.provider=singleFile -Dkeycloak.migration.file=initial_data.json -Dkeycloak.migration.strategy=OVERWRITE_EXISTING
Then it is executing perfectly, but I do need to add that realm-export.json file here.