Skip to content

Instantly share code, notes, and snippets.

@sventorben
Created March 10, 2022 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sventorben/34bc9b749f749815d534c886a8e1e062 to your computer and use it in GitHub Desktop.
Save sventorben/34bc9b749f749815d534c886a8e1e062 to your computer and use it in GitHub Desktop.

Container mit Admin User starten

Keycloak

docker run --rm \
    -p 80:8080 \
    -e KEYCLOAK_USER=admin \
    -e KEYCLOAK_PASSWORD=admin \
    quay.io/keycloak/keycloak:16.1.1

Erster Start eines Keycloak-Servers mit administrativem Benutzer.

Keycloak-X

docker run --rm \
    -p 80:8080 \
    -e KEYCLOAK_ADMIN=admin \
    -e KEYCLOAK_ADMIN_PASSWORD=admin \
    quay.io/keycloak/keycloak:17.0.0 \
    start-dev

Erster Start eines Keycloak-Servers mit administrativem Benutzer. Die Umgebungsvariablen haben sich geändert.

Context-Pfad setzen

Keycloak

docker run --rm \
    -p 80:8080 \
    quay.io/keycloak/keycloak:16.1.1

Keycloak ist standardmäßig unter dem Context-path https://localhost/auth verfügbar.

Keycloak-X

docker run --rm \
    -p 80:8080 \
    -e KC_HTTP_RELATIVE_PATH=auth \
    quay.io/keycloak/keycloak:17.0.0 \
    start-dev

In der neuen Version ist der Context-Path standardmäßig leer (https://localhost/), kann aber mittels KC_HTTP_RELATIVE_PATH gesetzt werden.

HTTPS aktivieren

Keycloak

openssl req -x509 -newkey rsa:4096 \
    -keyout https/tls.key \
    -out https/tls.crt \
    -sha256 -days 365 -nodes \
    -subj '/CN=keycloak'

docker run --rm \
    -p 443:8443 \
    -v $PWD/https:/etc/x509/https/ \
    quay.io/keycloak/keycloak:16.1.1

Für Keycloak genügt es die entsprechende Zertifikate zu generieren und zu mounten.

Keycloak.X

openssl req -x509 -newkey rsa:4096 \
    -keyout https/tls.key \
    -out https/tls.crt \
    -sha256 -days 365 -nodes \
    -subj '/CN=keycloak'

docker run --rm \
    -p 443:8443 \
    -v $PWD/https:/etc/x509/https/ \
    quay.io/keycloak/keycloak:17.0.0 \
    start --hostname=keycloak \
    --https-certificate-file=/etc/x509/https/tls.crt  \
    --https-certificate-key-file=/etc/x509/https/tls.key

Für Keycloak.X muss zusätzlich der Hostname sowie die Zertifikats- und Schlüsseldatei angegeben werden.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment