-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker for windows is not mapping ports to localhost #204
Comments
Running the same type of -p option on Windows 2016 also does not work. On the Windows 2016 I tried all of the available ip addresses but only the address shown from docker inspect and the original port from the EXPOSE statement worked. I could swear this worked before, and have been doing this for all of this year with the linux/mac versions of docker. |
@panmanphil thanks for the report. Probably confusing, but networking for Windows containers is done differently to the way we run Linux containers on Windows (and the Mac). For Linux containers we use a component, called VPNKit, which watches containers with exposed ports being created and exposes them on the localhost. For Windows containers this component is not used and containers and their ports are only accessible via the NATed IP address. This is expected behaviour and I'm closing this issue. We should probably add this to our documentation (/cc @londoncalling). |
This isn't just the loopback connector that isn't working. I tried all the ip addresses on the box listed from ipconfig, and none of them could be used to connect. Only the nated container ip address and port worked. What is the purpose of having -p then if not to put the port on one of the host's ip addresses? Yes please do update the documentation, I can't be the first to spend a bunch of time on this. |
@panmanphil the containers are currently only available on the container IP:
Details here: https://blog.sixeyed.com/published-ports-on-windows-containers-dont-do-loopback/ |
Is this still an issue. Because I tried it with the lastest version of Docker on Win10Pro and |
This is still an issue but if/when it will be resolved seems murky. For anyone else that might be frustrated, I've put together an admittedly sub-optimal work-around for this limitation, DockerProxy. It's a dotnet core console app that proxies from localhost:{port} -> docker-container:{port}. It monitors docker and will start/stop listening on ports as containers come up or down. |
For me NATing the port in VirtualBox worked |
@jonstelly : thanks for the docker proxy. But it doesn't seem to work for me. I just start it on my Windows 7 Home like this:
Starting stopping docker image via |
Ok, I digged deeper into the rabbit hole and debugged/compiled my own version to see what's the problem here. Forget about the listening stuff I wrote :). First of all, I have to run the docker tools (docker-machine) on my Windows 7. I think this is the main reason, that DockerProxy is not working out of the box. I did two things to make it work: In I think it should be possible to get that IP via |
This is ridiculous... This should work out of the box! And this is still not mentioned in documentation or am I missing something?! Moreover default machine created like in getting started guide is not NAT-ted so doing anything like docker inspect --format '{{ .NetworkSettings.Networks.nat.IPAddress }}' returns only This issue should be reopened and fixed properly. Instead of avoiding the proper solution. This is at end what docker should just do without excuses. Why do anyone need docker container with no possibility to connect to it anyway? Edit: |
In the end I switched to Windows 10 Professional since this solution wasn't reliable :(. I wanted to avoid that at all costs. But docker and Win7 is a pain. With the native docker it works quite well now! |
The only way we can access exposed port in windows is through
. I have tried every ip address listed in my ipconfig -all list. At last I found the correct ip from command docker-machine ip. Worked for me in windows 10 pro. |
I found this very good blog article where it explains how to get around this.
Using the -P flag apparently assigns a randomised port number to expose. Reassuringly I saw a Windows Security Alert:
but, dissapointingly... http://10.0.75.0:32769 still gives me |
Thanks @joshijimit, I eventually tried your tip of trying all of the addresses given by
|
Glad to hear it helps you @nickweavers. And yes I am also not sure why there is a conflict in IP address in Windows with docker. |
Hi all, We now have support for using localhost/loopback to access your container's published ports on Windows 10! Here's the announcement for this support, which is available starting with Windows 10 Insider build 17025. Have any of you been able to try this already? If so, we'd love to hear your feedback. Let us know whether or not this support is meeting your needs. Feel free to reply here with comments or email our team at [email protected]. --Kallie Bracken |
Cool I will give it a try.. Thanks for update. |
Sadly not working
Now we can try again
This time we're good, but is this what you meant by
since there was no mention of having to use the -p flag? |
Hi, I am new on this stuff, could I know is the "exposed" work properly in microsof/iis? docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" amazing_wiles ed2248e00f74 microsoft/iis "C:\ServiceMonitor..." 12 minutes ago Up 12 minutes 0.0.0.0:12345->80/tcp amazing_wiles |
@kimtso , As per the comment from @kallie-b and @nickweavers it seems you should be able to access iis through localhost:80 (i.e just localhost) if you are using the latest build. If you can't, try to run "docker-machine ip" command in your docker terminal and use that ip to access your IIS. |
@joshijimit, where does the docker-machine command come from? It doesn't appear to be part of the docker client. My docker clients is
Am I missing something?
|
So is the issue where docker doesn't map the ports to localhost a regression we're all going to ignore? I've been using docker-for-win and it has been happily mapping the ports up until a couple months ago and again recently. It maps the local ports for mac and linux, why would it not for windows? No amount of restart/reinstall of docker has fixed this issue. It just loses all port mapping while the containers are running. |
Why this issue closed? And how to solve it? |
@hadaev8 Apparently we just have to deal with the issue as it's not going to be fixed. Just restart your computer and reinstall docker everytime or buy a mac/install linux if you want a better experience. |
My guess is that Docker on WSL2 will improve this experience... Hopefully. |
Still getting the same issue, tried all options discussed above. I am not understanding why this issue marked as closed. |
I am still having this problem. What is the recommended work around? |
I just stopped using it for a month and it started working. |
I had the same issue. To get the actual ip, use "docker-machine config". Use this ip instead of localhost. |
That's a non-solution for any development that deals with OAuth integration and is unique to windows only. Works perfectly fine on Mac and Linux on localhost and Windows should be the same. |
Hello guys, I think I found a solution for .net core applications. It seems that this is a configuration problem but not a Docker problem (at least at the present, maybe it was a Docker problem in the past). So the solution that worked for me: In your Program.cs add .UseUrls("http://+:<your_port>") and try. This is in case that you are hosting your web application in the default .net core's web server Kestrel. By using the UseUrls method you are telling where the Kestrel web server should listen. Anything from the launchSettings.json file does not matter. |
Someone proposes as a workaround to access If I have a server in a Docker container, the docs say it can be accessed like How useful is a server that can only be accessed from the host machine? Or is there a way to expose it "publicly"? (BTW, this is Docker Toolbox on Windows 10 Home) |
For Windows, try this - Go to cmd, run ipconfig Wireless LAN adapter Wi-Fi: Connection-specific DNS Suffix . : docker run -d --name webs -P httpd docker ps then, use ${000000000}:32768 |
Because on Windows < 10, docker doesn't map ports on localhost, see docker/for-win#204
This worked for me. Routed all machine Port 80 host requests to Docker machine IP on Port 80:
obtained docker machine IP : docker-machine ip 'machine name' machineIP:80 on browser |
Issue still exist for me on windows 10 Pro, Build 18363. |
Got it to work using a combination of @szydan comment:
along with @joshijimit comment:
|
A simpler way is to just use docker inspect to get the ipadress
|
thanks @joshijimit , its really helpful, |
So disappointing to see this issue is still around after more than three years. And yes - I've wasted hours too trying to fix it before I stumbled on this thread. docker network create --subnet 172.18.01.0/24 --driver nat sql_net docker run -itd --network sql_net --ip 172.18.01.12 -v e::e: humphriesj/windowssql:2019 In this case the SQL server image is then available at 172.18.01.12:1433 always. |
<http://docker-machine ip:exposed port> works for me, I can see the view in the browser. |
For folks not able to use Docker on Windows because we don't have Pro, Enterprise, or Education edition, this was the correct way to get this all working. Thank you! |
Closed issues are locked after 30 days of inactivity. 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. |
Expected behavior
Using a simple example of the FROM microsoft/iis and EXPOSE 8000 as shown in the samples, this type of command runs, and I can access the port on the ip address shown from docker inspect. However when I use port mapping like so:
docker run -d -p 8080:8000 --rm iissite
I expect to be able to access the site from http:/localhost:8080, instead only the nat ip and EXPOSE port are reachable.
Actual behavior
unable to connect
Information
Client:
Version: 1.12.0
API version: 1.24
Go version: go1.6.3
Git commit: 8eab29e
Built: Thu Jul 28 23:54:00 2016
OS/Arch: linux/amd64
Server:
Version: 1.12.2-cs2-ws-beta
API version: 1.25
Go version: go1.7.1
Git commit: 050b611
Built: Tue Oct 11 02:35:40 2016
OS/Arch: windows/amd64
windows version 1607 build 14393.351
Dockerfile
FROM microsoft/iis
RUN mkdir C:\site
RUN powershell -NoProfile -Command
Import-module IISAdministration;
New-IISSite -Name "Site" -PhysicalPath C:\site -BindingInformation "*:8001:"
EXPOSE 8001
ADD . /site
Steps to reproduce the behavior
docker run -d --name site iissite
(from powershell)
docker inspect --format='{{.NetworkSettings.Networks.nat.IPAddress}}' site
wget "http://:8001" -UseBasicParsing
You see StatusCode 200
docker stop site
docker rm site
docker run -d -p 8080:8001 --name site iissite
wget "http://localhost:8080" -UseBasicParsing
get "unable to connect to the remote server"
also try trying the ip of ethernet0 from ip config
with linux containers and previous version of docker for windows, this works and works well
The text was updated successfully, but these errors were encountered: