Home > other >  Docker: Connect to Wildfly server from outside
Docker: Connect to Wildfly server from outside

Time:08-31

I am having trouble connecting to a Wildfly server running in a Docker Desktop container. My Dockerfile is like so:

FROM jboss/wildfly:9.0.1.Final
COPY ./standalone-template.xml /opt/jboss/wildfly/standalone/configuration/standalone.xml
COPY ./MyApplication.war /opt/jboss/wildfly/standalone/deployments/MyApplication.war
CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]

The server seems to start successfully, and at the end of the output from the CMD running docker run -it mydockerimage I see this output:

19:20:21,260 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 62) WFLYUT0021: Registered web context: /MyApplication
19:20:21,338 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 34) WFLYSRV0010: Deployed "MyApplication.war" (runtime-name : "MyApplication.war")
19:20:21,568 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0061: Http management interface listening on https://0.0.0.0:9993/management
19:20:21,569 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0052: Admin console listening on https://0.0.0.0:9993

However, I am not able to connect to the server's admin console or the application from my machine's browser, I get ERR_CONNECTION_REFUSED. When I modify the docker run command to be docker run -it -p 9993:9993 mydockerimage I am able to connect to the admin console, but I can't do the same for the application itself. Normally for an https Wildfly server I wouldn't use any port when trying to connect through the browser, but trying to do https://localhost/MyApplication fails.

What should I change to allow connection to the "MyApplication" web context?

CodePudding user response:

You need to include port 8080 in run command

docker run -it -p 8080:8080 -p 9993:9993 mydockerimage

and access your application at not https://localhost/MyApplication but at https://localhost:8080/MyApplication, or any other port that you choose in -p 8080:8080 for host port.

  • Related