I run keycloak standalone using a command for docker docker run -p 8080:8080 -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin quay.io/keycloak/keycloak:15.0.2
How to mount a volume to save the data, after container is stopped?
I run keycloak standalone using a command for docker docker run -p 8080:8080 -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin quay.io/keycloak/keycloak:15.0.2
How to mount a volume to save the data, after container is stopped?
Keycloak comes with its own embedded Java-based relational database called H2.
The data is stored in /opt/jboss/keycloak/standalone/data/ inside the container.
To start the container with a mounted volume you need:
mkdir -m 777 ./keycloak_data
docker run -v ./keycloak_data:/opt/jboss/keycloak/standalone/data/ -p 8080:8080 -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin quay.io/keycloak/keycloak:15.0.2
Note that if you mount the volume, the KEYCLOAK_USER and KEYCLOAK_PASSWORD will only be considered by the first start of the container, so to start the container again just use:
docker run -v ./keycloak_data:/opt/jboss/keycloak/standalone/data/ -p 8080:8080 quay.io/keycloak/keycloak:15.0.2