3

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

$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.
4
  • Is your web app listening on port 5000? Commented Nov 10, 2015 at 21:50
  • Yep, port 5000 (it's the default for the server that run dotNet core). I even logged to the container and tried to start the server again on this port but error pop ups that the port already have listener attached (assume that the server is working as expected). Commented Nov 10, 2015 at 22:09
  • Maybe the container needs some time to start. Could you run docker logs web to see if the app inside the container is completely started? Commented Nov 10, 2015 at 22:34
  • Here are the logs - I added them as edit to my initial post. Commented Nov 10, 2015 at 22:37

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

When I first tried to just access the container using the port 5000 did not succeeded (as seen here pastebin.com/zNELZiY5). Then I tried to modify the Dockerfile / project.json as you suggested and everything start working flawlessly! Thank you very much!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.