Keyclock outside from Docker (another service on local machine) - Seems I cannot connect from outside


I´m sorry, I´m a beginner.
I have two question

I defined my Dockerfile like:


RUN /opt/jboss/wildfly/bin/ admin admin --silent

COPY my-standalone.xml /opt/jboss/wildfly/standalone/configuration/
COPY myapp.war /opt/jboss/wildfly/standalone/deployments/
COPY module.xml /opt/jboss/wildfly/modules/system/layers/base/com/mysql/main/
COPY mysql-connector-java-8.0.12.jar /opt/jboss/wildfly/modules/system/layers/base/com/mysql/main/

EXPOSE 8080 9990

# Run with custom configuration
CMD ["/opt/jboss/wildfly/bin/", "-b", "", "-bmanagement", "", "-c","my-standalone.xml"]

If I start docker my wildfly application and server it´s running.
But I have also a dependency to a Keyclock application, which runs on my local machine (another process, not from docker…).
It seems Docker is not able to use this from my application.
The URL from Keyclock is:

What do I need to change?

And my second question is, if I use on top a docker-compose.yaml file, which is also using the Dockerfile. Do I need to change something also there to get Keyclock running / considering?

Thanks for your help is not an ip address as such, but it indicates to “listen on all available IP addresses” to an application.

To connect to a service listening on, you need to use a real IP address. The host usually has localhost/ and a custom one like As localhost within a container is really only localhost within container, not on host, you must use the other IP to connect.

Thank you - you are right: http://localhost:9009/auth is also working.
But I still don´t understand where I have to define this URL in the Dockerfile or docker-compose.yaml file ?

In my app I defined the URL only here:

oidcConfig.discoveryURI = http://localhost:9009/auth/realms/myapp/.well-known/openid-configuration
oidcConfig.clientId = myapp

But it seems Docker cannot access http://localhost:9009

Let me rephrase my post:

Within a container you can not use localhost to connect to a service listening on hosts localhost.

… unless the container uses the host network. Since we never saw the compose file, it could be why @vished2000 repots that localhost is working for him.

The only reason why I would use the host network, is when I have a container that needs to act on udp broadcast traffic. For everything else I would not want to lose the network namespace isolation provided by bridge networks.

1 Like