Cannot Connect Keycloak docker to mssql database

Same here. In my case I’m using a docker-compose.yml with image image: “Quay
I connect to an external mssql server where it creates a database. When the database is filled with seed data I get the same error.

Violation of UNIQUE KEY constraint “UK_CLI_SCOPE”. A duplicate key cannot be inserted into the dbo.CLIENT_SCOPE object. The duplicate key value is (a8be7b83-30ee-4b12-ab6d-3bfd063ea213, role_list).

No data or even tables are created in the database. JPA might do a full rollback because of the primary key error.
I used an environment variable to see -verbose logs: KC_LOG_LEVEL=DEBUG

Questions:
Is that just happening with sqlserver?
How did you fix it?
is there a problem with the creation script that JPA generates?

I fond a post about how to export the script cloak-database-creation-keycloak.sql. I couldn’t manage to configurate the export with docker-compose environment variables.

Any ideas or help will be very very welcome. :slight_smile: