Docker Community Forums

Share and learn in the Docker community.

Trouble connecting to apache webserver on Docker container from host

Hi, I’m on Windows 10, I’ve installed Docker for Desktop and I have an Ubuntu server that I’m working on in a container called ‘dev01’.

I’ve started the container with:

docker start dev01

Then I execute:

docker network inspect bridge

From this I can see the IP address of ‘dev01’ is
I was hoping to access the website on the server by putting the ip address straight into my browser but it does not connect. When I ping from Windows cmd I get time outs.

I know the page is up and running on the container as from within the container I can use ‘lynx’ to view the page.

Is there a way to access a container from the host’s web browser?


Just noticed when I run ipconfig I have a DockerNAT adapter but it has no gateway:

   IPv4 Address. . . . . . . . . . . :
   Subnet Mask . . . . . . . . . . . :
   Default Gateway . . . . . . . . . :

Is that significant?


I’ve been looking at and using his pre-made example I can see that the container starts up with ports exposed and I can access it…

 docker run -d -P --name static-site prakhar1989/static-site

If I do the same with one of my images (Ubuntu with Apache and PHP) the container exits immediately and I can’t start it. Can anyone explain this as I’m having trouble tracking the reason for this down.


In your docker run command, you have -P, which maps to RANDOM local ports, if you use:

docker port static-site

It will give you something like:

11333/tcp ->

which means, that you need to access: http://localhost:11333 (in my case) to access the port 80 running in the container.

1 Like

Thanks, I finally got to a solution by starting a container as follows:
docker run -i -p 808:80 -td image_name
Where 808 is the port on the host and 80 the port in the container that I want to be pused out to 808.
Then I can access the webserver with:
This is working for me at the moment.

1 Like