Docker Community Forums

Share and learn in the Docker community.

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 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 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?


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 either use localhost (or its ip 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.

Sunag R A.