Keycloak Docker - Migration & Restart

Hello there,

I’m currently using Keycloak v14.0.0 within Docker image.
However, after a first sucessful boot of Keycloak, it fails to start in the following retries.

I think that is somehow related with realm migration configurations since this only happens when docker references json export files.

This is the docker-compose configuration file used with different approaches (please, see the comment parameters) to import and overwrite existing realms, although none of them worked.

services:
  keycloak:
    image: vidar:5000/keycloak/keycloak:latest
    ports:
      - "8502:8443"
      - "8503:9990"
    environment:
     KEYCLOAK_USER: admin
     KEYCLOAK_PASSWORD: <password>
     X509_CA_BUNDLE: <certificate>
     DB_VENDOR: POSTGRES
     DB_ADDR: postgres
     DB_DATABASE: keycloak
     DB_USER: keycloak
     DB_SCHEMA: public
     DB_PASSWORD: <password>
     KEYCLOAK_STATISTICS: db,http
     KEYCLOAK_IMPORT: /opt/jboss/keycloak/Config/DockerDemo-v1-realm.json, /opt/jboss/keycloak/Config/DockerDemo-v2-realm.json, /opt/jboss/keycloak/Config/DockerDemo-v3-realm.json
     #KEYCLOAK_MIGRATION_STRATEGY: OVERWRITE_EXISTING
     #KEYCLOAK_PATH: /opt/jboss/keycloak/Config
    volumes:
     - /mnt/keycloak/data:/opt/jboss/keycloak/standalone/data
     - /mnt/keycloak/certs:/etc/x509/https
     - /mnt/keycloak/Config:/opt/jboss/keycloak/Config
    deploy:
     replicas: 1
    depends_on:
     - postgres
    #command:
    # - "-Dkeycloak.migration.action=import -Dkeycloak.migration.provider=dir -Dkeycloak.migration.dir=/opt/jboss/keycloak/Config"
    #command:
     #[
      #'-Djboss.socket.binding.port-offset=100',
      #'-Dkeycloak.migration.action=import',
      #'-Dkeycloak.migration.provider=dir',
      #'-Dkeycloak.migration.dir=/opt/jboss/keycloak/Config',
     #]
    #command:
    # - "Dkeycloak.profile.feature.upload_scripts=enabled"
    # - "Dkeycloak.import=/opt/jboss/keycloak/Config/DockerDemo-v1-realm.json,/opt/jboss/keycloak/Config/DockerDemo-v2-realm.json,/opt/jboss/keycloak/Config/DockerDemo-v3-realm.json"
  postgres:
    image: vidar:5000/postgres:latest
    environment:
     POSTGRES_DB: keycloak
     POSTGRES_USER: keycloak
     POSTGRES_PASSWORD: <password>
    volumes:
     - /mnt/keycloak/postgres_data:/var/lib/postgresql/data
    deploy:
     mode: replicated
     replicas: 1

I know that this kind of issue was known by RedHat and already solved within version 12 (Allow container to be stopped and started by tmewett · Pull Request #286 · keycloak/keycloak-containers · GitHub).
But since I’m using v14, I don’t see any other possibility for this behaviour.

Thank you in advance,
Best regards,
Iuri Figueiredo