I'm trying to configure a dockerized Keycloak server like creating a realm from CLI command in the Dockerfile:
FROM quay.io/keycloak/keycloak:11.0.0
# Create realm "realm_borrar" on keycloak
RUN /opt/jboss/keycloak/bin/kcadm.sh create realms -s realm=my_new_realm -s enabled=true -o --server http://localhost:8080/auth --realm master --user admin --password admin
The result of docker build -f ...
is:
Logging into http://localhost:8080/auth as user admin of realm master
Failed to send request - Connect to localhost:8080 [localhost/127.0.0.1] failed: Connection refused (Connection refused)
If I run the container (created with the same Dockerfile but removing the RUN sentence) and I execute the same CLI command (kcadm.sh ....) it works.
What should be the proper way to config Keycloak in the Dockerfile?
Thanks.
/opt/keycloak/bin/kcadm.sh get realms --no-config --server http://localhost:8080 --realm master --user admin --password admin
– Gunplay