docker / for-win

Bug reports for Docker Desktop for Windows
https://www.docker.com/products/docker#/windows
1.86k stars 290 forks source link

Container 'does not send any data' when request is sent #197

Closed aysark closed 7 years ago

aysark commented 7 years ago

I have a dockerfile thats based off ubuntu 16.04 and i install a proprietary product thats powered by tomcat and exposes a webserver. Then i run:

$ docker build -t p-installer:b6489 .
$ docker run -d -p 7080:7080 --name pcontainer --hostname pcontainer -t p-installer:b6489

Using Docker for Windows latest (1.12.1), i try to access the container from my local docker build machine (http://172.17.0.2:7080) and am unable to- the response on chrome:

The 172.17.0.2 page isn’t working

172.17.0.2 didn’t send any data. ERR_EMPTY_RESPONSE

But I can see in the docker internal logs that its passing my request to the container but there is an error also logged:

[13:25:48.965][VpnKit         ][Debug  ] com.docker.slirp.exe: tcp:0.0.0.0:7443:tcp:172.17.0.2:7443: connected
[13:26:10.024][VpnKit         ][Debug  ] com.docker.slirp.exe: tcp:0.0.0.0:7443:tcp:172.17.0.2:7443 completed: l2r = 1.5 KiB bytes at 75 bytes/sec and 0.2 IOPS/sec; r2l = 893 bytes bytes at 42 bytes/sec and 0.1 IOPS/sec
[13:27:34.589][VpnKit         ][Error  ] com.docker.slirp.exe: Socket.TCPV4.read connected TCP: caught Uwt.Uwt_error(Uwt.ECONNRESET, "uwt_read", "") returning Eof
[13:27:34.590][VpnKit         ][Debug  ] com.docker.slirp.exe: tcp:0.0.0.0:7443:tcp:172.17.0.2:7443 completed: l2r = 1.6 KiB bytes at 60 bytes/sec and 0.2 IOPS/sec; r2l = 555 bytes bytes at 3 bytes/sec and 0.0 IOPS/sec
[13:38:28.196][VpnKit         ][Error  ] com.docker.slirp.exe: Socket.TCPV4.read connected TCP: caught Uwt.Uwt_error(Uwt.ECONNRESET, "uwt_read", "") returning Eof
[13:38:28.197][VpnKit         ][Debug  ] com.docker.slirp.exe: tcp:0.0.0.0:7443:tcp:172.17.0.2:7443 completed: l2r = 46.4 KiB bytes at 58 bytes/sec and 0.2 IOPS/sec; r2l = 24.3 KiB bytes at 30 bytes/sec and 0.1 IOPS/sec
[13:38:38.196][VpnKit         ][Debug  ] com.docker.slirp.exe: tcp:0.0.0.0:7443:tcp:172.17.0.2:7443: connected
[13:50:33.642][Analytics      ][Info   ] Usage Statistic: heartbeat
[13:52:48.829][VpnKit         ][Error  ] com.docker.slirp.exe: Socket.TCPV4.read connected TCP: caught Uwt.Uwt_error(Uwt.ECONNRESET, "uwt_read", "") returning Eof
[13:52:48.830][VpnKit         ][Debug  ] com.docker.slirp.exe: tcp:0.0.0.0:7443:tcp:172.17.0.2:7443 completed: l2r = 29.9 KiB bytes at 35 bytes/sec and 0.2 IOPS/sec; r2l = 23.4 KiB bytes at 28 bytes/sec and 0.1 IOPS/sec

I do the same above steps on a linux docker host machine and i am able to access the container fine. I can only repro on a windows machine.

Information

rn commented 7 years ago

does it work with http://localhost:7080?

aysark commented 7 years ago

@rneugeba no, i tried localhost, 127.0.0.1 and also the machine's ip.

When i do localhost:7080 or 127.0.0.1:7080, it redirects me to localhost:7080/home which is correct as that is what our app does (returns a 301 redirect to another page to follow). However, then it returns a error response or no data received response. Note: when i do the same exact steps on Ubuntu host machine, it works fine.

So my hunch is Docker for Windows is somehow not handling the request/responses correctly.

friism commented 7 years ago

@aysark Docker for Windows doesn't intercept individual HTTP requests. The fact that your app successfully redirects to /home also suggests that networking is working correctly.

To help us reproduce, would you provide a smaller test-case not involving your proprietary software, that demonstrates the problem?

aysark commented 7 years ago

So after some further investigating i fixed it. Basically I had to make the containerized app expect requests from the windows host machine ip (not container ip). Didn't have to do that on linux.

friism commented 7 years ago

@aysark ok, so this was because your app was looking at the host header and expecting localhost and seeing something else?

aysark commented 7 years ago

@friism yes. The app was designed to look for the container's IP/hostname.

friism commented 7 years ago

@aysark roger, thanks - just checking to see if I should close the issue: in your opinion, is this a problem with how Docker works?

aysark commented 7 years ago

Well... its certainly confusing that the way Docker for Windows/OSX and Linux work. And its not documented. I spent a good time going back and forth with my colleague who was running the container fine on ubuntu and we were scratching our heads thinking it was our app. In the end.. it seems that Docker for Windows proxy process routes the request to the container as the host windows machine while- this is not the case for linux (its as the container ip).

-Aysar

On Mon, Nov 7, 2016 at 10:40 AM, Michael Friis notifications@github.com wrote:

@aysark https://github.com/aysark roger, thanks - just checking to see if I should close the issue: in your opinion, is this a problem with how Docker works?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/docker/for-win/issues/197#issuecomment-258923086, or mute the thread https://github.com/notifications/unsubscribe-auth/AAn8FMuDoLe9PmRtGboxi1TBBoSuTvECks5q73CpgaJpZM4KnyHt .

friism commented 7 years ago

Sweet, thanks a lot. @londoncalling we should perhaps look at putting this in the FAQ, maybe @rneugeba can help.

jstray commented 7 years ago

I just lost a day to this problem on Docker for Mac. The requirement to bind to a non-localhost IP really needs to be better documented.

RapiDash1 commented 5 years ago

So after some further investigating i fixed it. Basically I had to make the containerized app expect requests from the windows host machine ip (not container ip). Didn't have to do that on linux.

can you please explain this, i'm new to flutter.

dotun commented 5 years ago

So after some further investigating i fixed it. Basically I had to make the containerized app expect requests from the windows host machine ip (not container ip). Didn't have to do that on linux.

@aysark could you shed some more light on what this involves?

docker-robott commented 4 years ago

Closed issues are locked after 30 days of inactivity. This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. /lifecycle locked