DEV Community

Discussion on: Keycloak Express Openid-client

Collapse
 
austincunningham profile image
Austin Cunningham

There has to be a better way to get the docker0 ip address. This will get it

ifconfig | awk '/docker0/{getline; print}' | awk '{ print $2 }'
Enter fullscreen mode Exit fullscreen mode

You can then create an environment variable

export DOCKERHOST=$(ifconfig | awk '/docker0/{getline; print}' | awk '{ print $2 }')
Enter fullscreen mode Exit fullscreen mode

Change the issuer to use the environment variable

const keycloakIssuer = await Issuer.discover("http://"+ process.env.DOCKERHOST +":8080/realms/keycloak-express")
Enter fullscreen mode Exit fullscreen mode

Can pass it in on docker run

docker run -p 3000:3000 -e DOCKERHOST=$DOCKERHOST quay.io/austincunningham/keycloak-express-openid-client:latest
Enter fullscreen mode Exit fullscreen mode

For docker compose you can use a env file to pass in environment variables

Thread Thread
 
devtorello profile image
Tatiana Vitorello

Hey, Austin! Sorry for taking so long to reply, but I wanted to thank you for your help! It really helped me and worked like a charm! :)