2

I started to play around with docker for a while and got stuck with the below:

Here's my Environment:

Windows 10
boot2docker/Docker version 1.12.0
Virtual box 5.0.24

this is what i'm trying to do:

$ docker run -itp 8090:8090 lamp
root@8ebc390337be:/# service apache2 start
 * Starting web server apache2                                                                                                                                           *
root@8ebc390337be:/# service mysql start
 * Starting MySQL database server mysqld                                                                                                                           [ OK ]
root@8ebc390337be:/#

deattached from container and then

$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                    NAMES
8ebc390337be        lamp         "/bin/bash"         13 minutes ago      Up 13 minutes       0.0.0.0:8090->8090/tcp   happy_brown

$ docker inspect $(docker ps -q) | grep IPA
            "SecondaryIPAddresses": null,
            "IPAddress": "172.17.0.2",
                    "IPAMConfig": null,
                    "IPAddress": "172.17.0.2",

now when i try to run

$ curl 172.17.0.2:8090
curl: (7) Failed to connect to 172.17.0.2 port 8090: Timed out

then i tried

$ docker-machine ip default
192.168.99.100
$ curl 192.168.99.100:8090
curl: (7) Failed to connect to 192.168.99.100 port 8090: Connection refused

i did go through this accessing-a-docker-container-url-on-windows-host but it didn't help me.

i should be able to access the url from inside and outside the docker.

Could someone help me to troubleshoot

Community
  • 1
  • 1
JimK
  • 84
  • 4
  • to confirm your apache is running, could you go back inside the container and curl your local apache – vitr Aug 25 '16 at 07:41
  • this solved the problem: http://stackoverflow.com/questions/24969268/accessing-apache2-residing-inside-docker-container-from-host-machine-web-browser – JimK Aug 26 '16 at 10:29

1 Answers1

2

This is the ip address you should be using 192.168.99.100

I expect the problem is that your apache server is on port 80 inside the container, not 8090, i.e. your docker command should be:

$ docker run -itp 8090:80 linode/lamp

Which means map port 8090 on the outside host (192.168.99.100) to port 80 inside the container.

Matthew
  • 7,232
  • 2
  • 30
  • 50
  • thanks @matthew I was able to curl successfully within the docker terminal but still couldn't able to access it outside the terminal, via browser http://192.168.99.100:8090/ – JimK Aug 25 '16 at 08:43
  • Depends what you mean by 'outside'. That IP can only be accessed via your windows PC. You could setup routing / proxy so that you can access it more widely but that would be a question in itself! – Matthew Aug 25 '16 at 08:45
  • Yes, i couldn't able to access it via browser in my windows PC – JimK Aug 25 '16 at 08:47
  • i even tried adding rules in Virtualbox as stated here: http://stackoverflow.com/questions/33814696/how-to-connect-to-a-docker-container-from-outside-the-host-same-network-windo but still couldn't able to access it via browser. – JimK Aug 25 '16 at 09:34
  • when you `curl` it is it serving actual html? – Mano Marks Aug 26 '16 at 02:06
  • @ManoMarks Yes but only inside the docker terminal, but i would like to access it outside the terminal – JimK Aug 26 '16 at 04:38