Created
April 11, 2025 16:07
-
-
Save up1/4e18cb0fc56f2de4e0d4a3e809593e49 to your computer and use it in GitHub Desktop.
Keycloak 26.2 + Healthcheck + Docker compose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.keycloak.org/observability/health | |
services: | |
keycloak: | |
image: quay.io/keycloak/keycloak:26.2 | |
command: | |
- start-dev | |
- --import-realm | |
environment: | |
KEYCLOAK_ADMIN: admin | |
KEYCLOAK_ADMIN_PASSWORD: admin | |
DB_VENDOR: h2 | |
KC_HEALTH_ENABLED: true | |
ports: | |
- '8080:8080' | |
volumes: | |
- ./keycloak:/opt/keycloak/data/import | |
healthcheck: | |
test: ['CMD-SHELL', '[ -f /tmp/HealthCheck.java ] || echo "public class HealthCheck { public static void main(String[] args) throws java.lang.Throwable { System.exit(java.net.HttpURLConnection.HTTP_OK == ((java.net.HttpURLConnection)new java.net.URL(args[0]).openConnection()).getResponseCode() ? 0 : 1); } }" > /tmp/HealthCheck.java && java /tmp/HealthCheck.java http://localhost:9000/health/live'] | |
interval: 5s | |
timeout: 5s | |
retries: 30 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment