Thanks for idea. I spent half of the day to reach test environment with prepared data.
This thread doesn’t have how to get data from docker. I share.
First we need to understand how to get data.
this command start without running keycloak and you can run with bash /opt/keycloak/bin/kc.sh start-dev
Now we can add client and users. Open link http://localhost:8080/admin/. After stop server and execute next command to import data to directory /opt/keycloak/bin/kc.sh export --dir /tmp/import
copy from containter to localhost , execute from localhost where 4eb45b6c5063 - CONTAINER ID of the container , to find CONTAINER ID execute command docker ps docker cp 4eb45b6c5063:/tmp/import/ ./
Now we can create docker file and build
FROM quay.io/keycloak/keycloak:20.0.1
ADD ./import /opt/keycloak/data/import
RUN /opt/keycloak/bin/kc.sh import --dir=/opt/keycloak/data/import/ --override true; exit 0
ENTRYPOINT ["/opt/keycloak/bin/kc.sh", "-v"]`
Build docker build -t gdev.by/keycloak:0.2 .
and run docker docker run -p 127.0.0.1:8080:8080 -t gdev.by/keycloak:0.2 start-dev
For anyone messing with docker & bitnami/keycloak, I have a working solution to import both a custom master (/import/master) and a dev (/import/dev-realm) realm (dev-realm in my case):
Stderr output shown below is handled by 2>/dev/null
2022-12-26 04:03:28 2022-12-25 23:03:28,260 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to start server in (import_export) mode
2022-12-26 04:03:28 2022-12-25 23:03:28,261 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Script upload is disabled
2022-12-26 04:03:28 2022-12-25 23:03:28,261 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) For more details run the same command passing the '--verbose' option. Also you can use '--help' to see the details abou
After that it will start as normal
2022-12-26 04:03:51 2022-12-25 23:03:51,798 INFO [io.quarkus] (main) Keycloak 19.0.3 on JVM (powered by Quarkus 2.7.6.Final) started in 4.766s. Listening on: http://0.0.0.0:8080