Working from
Importing a Realm during Startup
You are also able to import realms when the server is starting by using the --import-realm
option.
bin/kc.[sh|bat] start --import-realm
When you set the --import-realm
option, the server is going to try to import any realm configuration file from the data/import
directory. Each file in this directory should contain a single realm configuration. Only regular files using the .json
extension are read from this directory, sub-directories are ignored.
My Current Dockerfile
FROM Quay as builder
ENV KC_HEALTH_ENABLED=true
ENV KC_METRICS_ENABLED=true
ENV KC_FEATURES=token-exchange
ENV KC_DB=postgres
Install custom providers
RUN curl -sL https://github.com/aerogear/keycloak-metrics-spi/releases/download/2.5.3/keycloak-metrics-spi-2.5.3.jar -o /opt/keycloak/providers/keycloak-metrics-spi-2.5.3.jar
RUN /opt/keycloak/bin/kc.sh build
FROM Quay
COPY --from=builder /opt/keycloak/ /opt/keycloak/
WORKDIR /opt/keycloak
for demonstration purposes only, please make sure to use proper certificates in production instead
RUN keytool -genkeypair -storepass password -storetype PKCS12 -keyalg RSA -keysize 2048 -dname “CN=server” -alias server -ext “SAN:c=DNS:localhost,IP:127.0.0.1” -keystore conf/server.keystore
change these values to point to a running postgres instance
COPY keycloak-export.json /keycloak-export.json
ENTRYPOINT [“/opt/keycloak/bin/kc.sh start --import-realm”]
The dockerfile, json file and the startup script all reside in the same folder of my computer
the error message as follows reads like I can’t use /opt/keycloak/bin/kc.sh start --import-realm or
/kc.sh start --import-realm
exec: “/opt/keycloak/bin/kc.sh start --import-realm”: stat /opt/keycloak/bin/kc.sh start --import-realm: no such file or directory: unknown.