Docker inside Linux VM cannot connect to web application

My setup is the following:

Host: Win10
Guest: Ubuntu 15.10 (clean install, only docker and nodejs are added)
Base image: https://hub.docker.com/r/microsoft/aspnet/ 1.0.0-beta8-coreclr

Inside the guest I have installed Docker and created image (added sample webapp using yeoman to the image above). When I run the image inside container I can ping the container IP sucessfuly using the container IP from the linux (e.g. 172.17.0.2).

  • How to load db2 dump data from the one db(remotly installed) to docker based db
  • Connect to docker-machine using docker-py (OSX)
  • what is the advantages of adopting content digest in docker?
  • Connecting to RDS Mysql from docker container with WordPress
  • Kubernetes multinode setup cannot remove docker0 interface
  • How can I access my docker maria db?
  • $sudo docker run -d -p 80:5000 --name web myapp
    
    $sudo docker inspect --format '{{ .NetworkSettings.IPAddress }}' "web"
    172.17.0.2
    
    $ping 172.17.0.2
    PING 172.17.0.2 (172.17.0.2) 56(84) bytes of data.
    64 bytes from 172.17.0.2: icmp_seq=1 ttl=64 time=0.060 ms
    1 packets transmitted, 1 received, 0% packet loss, time 999ms
    
    $curl 172.17.0.2:80
    curl: (7) Failed to connect to 172.17.0.2 port 80: Connection refused
    

    I can also connect to the container and execute commands like ping, however from the linux machine (guest in VirtualBox, host for docker) I cannot access the web app that is hosted inside the container as seen above. I tried several approaches like mapping to the host IP addresses etc, but none of them worked. Did anyone have ideas where to start from ? Is the issue comes from that the docker is installed inside VirtualBox machine?

    Thank you in advance.

    Edit: Here are the logs from the container:

    Could not open /etc/lsb_release. OS version will default to the empty string.
    Hosting environment: Production
    Now listening on: http://localhost:5000
    Application started. Press Ctrl+C to shut down.
    

  • Docker not reporting memory usage correctly?
  • Docker in docker connection error
  • Changing interface settings in Docker
  • Docker COPY command give 777 access to the copied file
  • renaming docker0 virtual bridge name to something else
  • Docker on mac: How to auto restart daemon processes after a machine reboot?
  • One Solution collect form web for “Docker inside Linux VM cannot connect to web application”

    Your command tells Docker to essentially proxy requests from port 80 of the Linux guest to port 5000 of the container. So the curl command you tried doesn’t work because you’re trying on port 80 on the container, while the container itself has a service listening on port 5000.

    To connect to the container directly, you would use (on the Linux guest):

    curl 172.17.0.2:5000
    

    To access via the published port on the Linux guest (from your host):

    curl (Linux guest IP)
    

    Or (from the Linux guest):

    curl localhost
    

    Edit: This will also prove to be problematic:

    Now listening on: http://localhost:5000
    

    You’ll want your app inside the container to bind to all interfaces (0.0.0.0) so it listens on the container’s assigned IP. With localhost it won’t be accessible.

    You might find this example useful:

    https://github.com/aspnet/Home/blob/dev/samples/1.0.0-beta8/HelloWeb/project.json

    This line specifies that the app bind to all interfaces (using “*”) on port 5004:

    21            "kestrel": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://*:5004"
    

    You’ll need similar configuration.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.