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: 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.

  • Use Concourse's docker resource to fetch containers to be used in a docker compose
  • Docker Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) Ubuntu
  • Docker for Windows Server 2016 requires update KB3176936
  • CrashLoopBackOff in spark cluster in kubernetes: nohup: can't execute '--': No such file or directory
  • Understanding code executed after run command in Docker
  • Vagrant docker provisioning with env variables and network
  • $sudo docker run -d -p 80:5000 --name web myapp
    $sudo docker inspect --format '{{ .NetworkSettings.IPAddress }}' "web"
    PING ( 56(84) bytes of data.
    64 bytes from icmp_seq=1 ttl=64 time=0.060 ms
    1 packets transmitted, 1 received, 0% packet loss, time 999ms
    curl: (7) Failed to connect to 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 responding to CTRL+C in terminal
  • How to ignore certificate errors in Boot2Docker on windows
  • Docker Container: time/timezone wrong
  • What environment variables can be used with a Docker image?
  • Docker and grunt-based workflow automation
  • Ansible and restarting a docker service
  • 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):


    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 ( so it listens on the container’s assigned IP. With localhost it won’t be accessible.

    You might find this example useful:

    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.