How to connect container service to host browser?

Dear all,

I am running a docker container in an office server. The container within is running an apache2 webserver on port 80. The docker container has been run with the following command:

docker run -it -p 8080:80 <docker-image>

From outside the container, I can see the status by using curl -I 0.0.0.0:8080 which says:

HTTP/1.1 200 OK
Date: Wed, 27 Oct 2021 07:00:54 GMT
Server: Apache/2.4.29 (Ubuntu)
Last-Modified: Tue, 19 Oct 2021 14:20:58 GMT
ETag: "468-5ceb55ec62680"
Accept-Ranges: bytes
Content-Length: 1128
Vary: Accept-Encoding
Content-Type: text/html

Now, when I use http://0.0.0.0:8080/ in my local browser, I am unable to see any page that is hosted by apache2.

What modification do I need to do? Am I missing anything in this?

Regards,

Sunag R A.

I am surprised that it even worked with curl. It must have tested the existing interfaces and tried to access port 8080 on each one of them, while the browser didn’t.

Instead of 0.0.0.0 either use localhost (or its ip 127.0.0.1) or the hostname (or its ip)
.

Dear meyay,

I tired with http://<ip-address>:8080 by giving the run command as docker run -p <ip-address>:8080:80 . This worked along with curl -I <ip-address>:8080. The webpage is displaying now.

Regards,
Sunag R A.

1 Like

I was working worked for this from two days and finally, it started working for me docker run -p 127.0.0.1:8080:80 tiredofit/freepbx before this i stopped the wamp server and skype because skype and mysql use 8080 port. when port was free and ip address was mentioned its started.

General remark: 0.0.0.0 is not an IP but rather a placeholder for “use all IPs”. So to access that service, you need to use localhost/127.0.0.1 or the local assigned IP address.