Can't connect to container on localhost with port mapping

thx a lot it’s on >>>>>>>>>>>>

Thanks. it solved my problem.

worked for me . Thanks a lot.

You save my life! thank you!

Worked for me , Thanks a alot @swethavisalam

Finally!!! Life Saviour :smiley:

worked!! Thanks a lot

Hi All, I have java application which I run using “javaws http://localhost:9088/rtccClient/rtcc.jnlp” from my windows machine. I created docker Linux container in my windows machine for my java application and it has ip “172.18.0.3” and in docker file I exposed 9080 port. I am running my docker as below.
“docker run --name recontainer17 -d -p 9088:9080 reimage17” after that I was trying to run the application as below.
“javaws http://localhost:9088/rtccClient/rtcc.jnlp”. but it was not working. please help how to run my java application from my windows host machine. I even tried as "javaws http://172.18.0.3:9088/rtccClient/rtcc.jnlp.
below is my docker file.
FROM ibmcom/websphere-liberty:latest
USER root
RUN yum -y install unixODBC
RUN yum -y install libaio
RUN mkdir -pv /basic
RUN mkdir -pv /resources/security
COPY ./basicinstaclient/oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm /basic/
RUN rpm -i /basic/oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm
ADD ./rtcc.ear /opt/ibm/wlp/usr/servers/defaultServer/apps
ADD ./rtccClient.war /opt/ibm/wlp/usr/servers/defaultServer/apps
ADD ./resources/bootstrap.properties /opt/ibm/wlp/usr/servers/defaultServer
ADD ./resources/server.xml /opt/ibm/wlp/usr/servers/defaultServer
ADD ./resources/hibernate/ /opt/ibm/wlp/usr/servers/defaultServer/hibernate
ADD ./resources/oracle/ /opt/ibm/wlp/usr/servers/defaultServer/oracle
ADD ./certificates/ /opt/ibm/wlp/usr/servers/defaultServer/resources/security
EXPOSE 9080

You should probably use the docker machine ip (usually http://192.168.99.100:xxxx) where xxxx is your mapped port, instead of http://localhost:xxxx (which won’t work because docker doesn’t control the “localhost” name, Windows does).
To get the machine ip, run

docker-machine ip

If you insist and still want to use “localhost” you have two options:

  1. A. Map a second port in VirtualBox from host (localhost:xxxx) to guest (your exposed docker port).

  2. B. Update your windows hosts file to map the “localhost” host name to the docker machine ip (c:\Windows\System32\drivers\etc\hosts) - comment out the line(s) that read:

    127.0.0.1    localhost
    ::1	localhost
    

    and add a line that reads:

    192.168.99.100	localhost
    

    But do so at your own peril - any servers that you are running or may run in the future outside of docker on localhost will no longer work.

I feel like this issue may be related. In my case I have been adapting an existing 32 application which I finally have running in a container built against windowsservercore ltsc2019.

The container exposes two ports, and when I run the container

docker run -dp 22737-22738:22737-22738/tcp mycontainer

it starts etc. If I exec -it a cmd.exe window and run netstat -an I see my two ports in there listening.

My host is a VM Windows server 2016 server.

Now, If I understand correctly, that -p option I provided maps my localhost 22737 and 22738 to the containers exposed ports of the same numbers, so I configured an application I have running on my host to attempt to connect to these ports using localhost.

My connection times out, however when I run netstat -an I see the the SYN_SENT status for both ports which implies maybe that the firewall inside my 2016 VM is blocking it. So, I opened the firewall manager and I believe I granted access to everything, because really at this point I would just like to see the host application execute a command with the container application.

What am I missing here?

I am not using the docker toolbox however I am running

Docker version 20.10.7, build 40ef3b6