Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing default port of keycloak in docker

Tags:

keycloak

I have logged in to virtual machine in docker but I can't find standalone.sh It isn't in /bin. I don't know also how to write dockerfile which set -Djboss.socket.binding.port-offset=100

like image 796
wwww Avatar asked Aug 09 '19 13:08

wwww


3 Answers

You can pass port as -Djboss.http.port parameter, for example:

 docker run --name keycloak -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin -p 11111:11111 jboss/keycloak -Djboss.http.port=11111
like image 53
Yuriy P Avatar answered Oct 16 '22 12:10

Yuriy P


Below is a sample docker-compose YAML file which shows you may set the offset in the command. Please kindly change according to your setting.

version: '2.1'
services:
  keycloak:
    image: jboss/keycloak:4.5.0.Final
    container_name: keycloak
    user: change_it
    hostname: change_it
    command: ["-Djboss.socket.binding.port-offset=0"]
    extra_hosts:
            - "change_it"
    environment:
      - KEYCLOAK_USER=change_it
      - KEYCLOAK_PASSWORD=change_it
    ports:
      - 8080:8080
      - 8443:8443

like image 5
Zhang Ran Avatar answered Oct 16 '22 13:10

Zhang Ran


This worked for me as in to change the default port of keycloak server through docker file. (keycloak runs on localhost:8100)

keycloak:
    build:
      context: ./keycloak
      dockerfile: ./Dockerfile
    environment:
      KEYCLOAK_USER: admin
      KEYCLOAK_PASSWORD: admin
      KEYCLOAK_DEFAULT_THEME: custom 
      KEYCLOAK_WELCOME_THEME: keycloak 
      DB_VENDOR: h2
    container_name: keycloak-container
    command: ["-Djboss.http.port=8100"]
    # Uncomment for development purpose
    # volumes:
    #   - ${PWD}/keycloak/theme/custom:/opt/jboss/keycloak/themes/custom
    ports:
      - 8100:8100
like image 1
suchita Avatar answered Oct 16 '22 12:10

suchita