I am trying to setup Keycloak using docker compose:
version: '2'
services:
keycloak:
image: jboss/keycloak:9.0.0
command:
[
'-b',
'0.0.0.0',
'-Dkeycloak.migration.action=import',
'-Dkeycloak.migration.provider=dir',
'-Dkeycloak.migration.dir=/opt/jboss/keycloak/realm-config',
'-Dkeycloak.migration.strategy=IGNORE_EXISTING',
'-Djboss.socket.binding.port-offset=1000',
'-Djboss.as.management.blocking.timeout=1000',
'-Dkeycloak.profile.feature.upload_scripts=enabled'
]
volumes:
- ./realm-config:/opt/jboss/keycloak/realm-config
environment:
- KEYCLOAK_USER=admin
- KEYCLOAK_PASSWORD=admin
- DB_VENDOR=MYSQL
- DB_ADDR=testmysqldb.mysql.database.azure.com
- DB_USER=testuser
- DB_PASSWORD=testpassword
- DB_DATABASE=keycloak
ports:
- 9080:9080
- 9443:9443
- 10990:10990
It takes long time to setup all the tables but eventually tables were created. However, I got timeout for jboss startup after some time. When I try to restart the the container, I get following error:
ERROR [org.keycloak.connections.jpa.updater.liquibase.conn.DefaultLiquibaseConnectionProvider] (ServerService Thread Pool -- 68) Change Set META-INF/jpa-changelog-authz-4.0.0.CR1.xml::authz-4.0.0.CR1::[email protected] failed. Error: Table 'resource_server_perm_ticket' already exists [Failed SQL: CREATE TABLE keycloak_new.RESOURCE_SERVER_PERM_TICKET (ID VARCHAR(36) NOT NULL, OWNER VARCHAR(36) NOT NULL, REQUESTER VARCHAR(36) NOT NULL, CREATED_TIMESTAMP BIGINT NOT NULL, GRANTED_TIMESTAMP BIGINT NULL, RESOURCE_ID VARCHAR(36) NOT NULL, SCOPE_ID VARCHAR(36) NULL, RESOURCE_SERVER_ID VARCHAR(36) NOT NULL)] 15:08:40,541 FATAL [org.keycloak.services] (ServerService Thread Pool -- 68) java.lang.RuntimeException: Failed to update database
I am unable to find any solution for how to solve this error. Basically, once tables exist, I expect keycloak NOT to try overwriting them. I am sure I am missing config here. Can someone help me?