[keycloak-user] How do you export a REALM from keycloak when running within a Docker container?

Melissa Palmer melissa.palmer at gmail.com
Wed Apr 17 00:47:56 EDT 2019


Thanks Bruno, I was specifically looking for ability to EXPORT a realm on a
running docker container. What's on the docker hub page and below is all
about importing an existing realm.

I did manage to solve this using the following:
If you start keycloak with::
docker run -d -p 8180:8080 -e KEYCLOAK_USER=admin -e
KEYCLOAK_PASSWORD=admin -e DB_VENDOR=h2 -v $(pwd):/tmp --name kc
jboss/keycloak:4.7.0.Final

You can then get the export from this instance by running:
docker exec -it kc keycloak/bin/standalone.sh
-Djboss.socket.binding.port-offset=100 -Dkeycloak.migration.action=export
-Dkeycloak.migration.provider=singleFile
-Dkeycloak.migration.realmName=my_realm
-Dkeycloak.migration.usersExportStrategy=REALM_FILE
-Dkeycloak.migration.file=/tmp/my_realm.json

Notice I am needing to go onto a currently running container and then
- run the export on a different port
- such that there are no port clashes of existing process running on that
container already

Thanks
Melissa


On Wed, 17 Apr 2019 at 06:10, Bruno Oliveira <bruno at abstractj.org> wrote:

> Hi Melissa, try something like this:
>
> docker run -d --name keycloak -e KEYCLOAK_USER=admin -e
> KEYCLOAK_PASSWORD=admin -p 8080:8080 \
> -v /path/to/yourrealm.json:/somepath/yourrealm.json \
> -it jboss/keycloak:master \
> -Dkeycloak.migration.action=import \
> -Dkeycloak.migration.provider=singleFile \
> -Dkeycloak.migration.file=/somepath/yourrealm.json \
> -Dkeycloak.migration.strategy=OVERWRITE_EXISTING
>
> I took all the information from
> https://hub.docker.com/r/jboss/keycloak/. I hope it helps.
>
> On 2019-04-15, Melissa Palmer wrote:
> > Hi
> >
> > How do you export a REALM from keycloak when running within a Docker
> > container?
> >
> > *If running Keycloak via docker, eg: using *
> > docker run -p 8080:8080 -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin
> > -e DB_VENDOR=h2 --name kc jboss/keycloak
> >
> > How can you export a realm that you have added via the UI?
> >
> > Thanks in Advance
> > Melissa
> > _______________________________________________
> > keycloak-user mailing list
> > keycloak-user at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/keycloak-user
>
> --
>
> abstractj
>


More information about the keycloak-user mailing list