Keycloak 8: User with username 'admin' already added Keycloak 8: User with username 'admin' already added docker docker

Keycloak 8: User with username 'admin' already added


Just to clarify the other answers. I had the same issue. What helped for me was:

  1. stop all containers
  2. comment out the two relevant lines

    version: "3"services:  keycloak:    image: quay.io/keycloak/keycloak:latest    environment:      # KEYCLOAK_USER: admin      # KEYCLOAK_PASSWORD: pass      ...
  3. start all containers;

  4. wait until keycloak container has successfully started
  5. stop all containers, again
  6. comment back in the two lines from above

    version: "3"services:  keycloak:    image: quay.io/keycloak/keycloak:latest    environment:      KEYCLOAK_USER: admin      KEYCLOAK_PASSWORD: pass      ...
  7. start all containers

This time (and subsequent times) it worked. Keycloak was running and the admin user was registered and working as expected.


This happens when Keycloak is interrupted during boot. After this, command which attempts to add admin user starts to fail. In Keycloak 7 this wasn't fatal, but in 8.0.1 this line was added to /opt/jboss/tools/docker-entrypoint.sh which aborts the entire startup script:

set -eou pipefail

Related issue: https://issues.redhat.com/browse/KEYCLOAK-12896


I had the same issue. After commenting out the KEYCLOAK_USER env variables in docker-compose and updating the stack, the container started again.

docker_compose:project_name: appauthrestarted: truepull: yesdefinition:  version: '2'  services:    keycloak:      image: jboss/keycloak:8.0.1      container_name: keycloak      restart: always      environment:        - DB_VENDOR=POSTGRES        - DB_ADDR=postgres        - DB_PORT=5432        - DB_SCHEMA=public        - DB_DATABASE=keycloak        - DB_USER=keycloak        - DB_PASSWORD=keycloak        #- KEYCLOAK_USER=admin        #- KEYCLOAK_PASSWORD=admin      networks:        - internal  networks:    internal:      external:        name: internal