Running Docker for Windows, Error when exposing Ports

DockerDocker for-Windows

Docker Problem Overview


I am aware there are a lot of questions about running Docker on windows, however this question is about running the brand new Docker for Windows, on Windows.
In my case I am using Windows 10 Pro 64 bit. According to the site this version should be supported.
I have been following a tutorial I found here: https://prakhar.me/docker-curriculum/
I also tried following the official guide of course: https://docs.docker.com/docker-for-windows/

In both tutorials I get the same error message when trying to assign a port using either the -P parameter or when trying to specify a port -p 8080:5000:

In the official guide I run docker run -d -p 80:80 --name webserver nginx and get:

>C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: driver failed programming external connectivity on endpoint webserver (f9946544e4c6ad2dd9cb8cbccd251e4d48254e86562bd8e6da75c3bd42c7e45a): Error starting userland proxy: mkdir /port/tcp:0.0.0.0:80:tcp:172.17.0.2:80: input/output error.

Following the unofficial guide i run docker run -p 8888:5000 prakhar1989/catnip and get basically the same error:

>C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: driver failed programming external connectivity on endpoint focused_swartz (48a0c005779c6e89bf525ead2ecff44a7f092495cd22ef7d19973002963cb232): Error starting userland proxy: mkdir /port/tcp:0.0.0.0:8888:tcp:172.17.0.2:5000: input/output error.

If I don't try to assign a port the container will run, but then I don't know how to access it.

The docker version I am running:

  • Docker version 1.12.3, build 6b644ec`
  • docker-compose version 1.8.1, build 004ddae`
  • docker-machine.exe version 0.8.2, build e18a919`

Any help would be very appreciated. Thank you.

Docker Solutions


Solution 1 - Docker

Here's a new twist.

The last Windows 10 update (Fall Creators Update, 2017) has a new "feature". It automatically starts any applications that were running when you last shutdown.

This reconstitutes Docker for Windows in a bad state. That made it appear those ports were in use by something else - it was the ghost of itself. This explained why those ports were still in use even though I stopped/started my containers and even reboot!

The solution in this case is to simply restart Docker daemon.

To prevent this after the next shutdown, don't use the shutdown button. Type this instead:

shutdown /s /t 0

This bypasses the new feature.

See the answer from Jason[MS] in this thread:

https://answers.microsoft.com/en-us/insider/forum/insider_wintp-insider_perf-insiderplat_pc/programs-autostart-after-boot-in-windows-10-fall/09dd8d3e-7b36-45d1-9181-6587dd5d53ab

Here's one guy's workaround (from the end of this thread - haven't tried it myself):

http://www.icttoolbox.nl/info/stop-windows-10-creator-fall-reopening-programs-reboot/

Solution 2 - Docker

Restarting the Docker daemon fixes this problem temporarily, but to get rid of it ultimately I had to disable Windows 10 fast startup, which is the feature @biscuit314 described.

To disable Windows 10 fast startup, get to the Control Panel > Power Options > Choose what the power buttons do > Change settings that are currently unavailable > Uncheck Turn on fast startup (recommended) and hit Save changes

Disable fast startup

Solution 3 - Docker

This is caused by a port numbering conflict: github issue here https://github.com/docker/compose/issues/3277

Essentially the port is in use! The reason resetting worked is because it wiped other mappings off.

Solution 4 - Docker

  1. Stop all the running containers docker stop $(docker ps -a -q) then

  2. Stop the Docker on your machine & restart it.

Then run the required command. This will solve the issue.

Solution 5 - Docker

If its in windows OS, Please do restart the Docker This has fixed the issue for me

Solution 6 - Docker

For Linux - Debian Users,

Use docker stop $(docker ps -a -q) only when you know whether you want to stop all the containers or not.... If yes then please run docker rm $(docker ps -a -q) to remove containers ....

Then stop the docker daemon - systemctl stop docker Then start docker daemon - systemctl start docker

Also verify whether docker daemon is up or not - service docker status

After following all above mention steps you should be fine.....

Solution 7 - Docker

Try stopping docker and initiating it again on administrator mode. After it starts open power shell on administrator mode as well. Because the error says "mkdir" maybe this will solve your problem. Im not sure but it worked for me. In the case of using -P a port conflict does not seen to be the reason for the error once -P will chose ports randomly. The error it self wasn't quite friendly to me but because I saw the mkdir word on it I imagined it might be a permission error, thats why I restarted docker on administrator mode and started power shell on administrator mode.

Solution 8 - Docker

I tried all the suggestions on this issue: killing all the containers, restarting Docker Desktop, disabling "Fast Startup," restarting my computer, making sure "Experimental Features" were disabled. None of that stuff worked.

I did eventually get it running. Here are some things you may want to try (because I'm not sure what actually fixed it).

  1. Find "Docker Desktop" and right-click to "Run as Administrator..."
  2. Pay attention to the port that it's complaining about. Some people say this could just be Docker's unfriendly way of saying "that port is in use." In my case, the port was 80. I went into the Services on Windows Pro and disabled the "World Wide Web Publishing Service" just to be safe.

Solution 9 - Docker

I got the same issue before on window 10. Restart docker, it works

Solution 10 - Docker

If you are here because you have this issue in Visual Studio 2019:

According to this post, the VS team is preparing a fix for this issue in 16.5 version, meanwhile, you can add the property "publishAllPorts": true in your launchSettings.json, for example:

"Docker": {
      "commandName": "Docker",
      "launchBrowser": true,
      "launchUrl": "{Scheme}://{ServiceHost}:44374", #<== Set a fixed port
      "environmentVariables": {
        "ASPNETCORE_URLS": "https://+:44374;https://+:5000",
        "ASPNETCORE_HTTPS_PORT": "44374"
      },
      "publishAllPorts": true, #<== This is equivalent to the -P flag in 'docker run'
      "useSSL": true
    }

Notice that the property "httpPort": XYZT is not defined. Having it defined will make the workaround not work.

It worked for me with this setup:

  • Windows 10 1709 Build 16299.1747 with Fast Start OFF
  • Docker Desktop 2.2.05 (43884)
  • Docker Engine 19.03.8
  • Visual Studio 2019 Enterprise 16.5.4.
  • Microsoft.VisualStudio.Azure.Containers.Tools.Targets 1.10.8

I realized that the command VS was creating, contained the -p parameter twice, one with the port I specified and another with port 80, like this: -p 3010:80 -p 3010:3010.

After adding publishAllPorts it now creates the container and I can remotely debug it.

Solution 11 - Docker

This is what worked for me after trying every thing. Seems we need to kill the running process.

  1. Exit docker, right-click the icon Quit Docker Desktop

  2. Open the windows task manager, find and kill the process com.docker.backend.exe

  3. restart docker, double-click the icon to open the Docker Desktop

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionS&#248;ren UllidtzView Question on Stackoverflow
Solution 1 - Dockerbiscuit314View Answer on Stackoverflow
Solution 2 - DockerPhonologView Answer on Stackoverflow
Solution 3 - DockerMrk FldigView Answer on Stackoverflow
Solution 4 - DockerSoumya BoralView Answer on Stackoverflow
Solution 5 - DockerAnoop GeorgeView Answer on Stackoverflow
Solution 6 - DockerAbhishek JainView Answer on Stackoverflow
Solution 7 - DockerJoao Carlos Costa LopesView Answer on Stackoverflow
Solution 8 - DockerAndrew KvochickView Answer on Stackoverflow
Solution 9 - DockerNhut NguyenView Answer on Stackoverflow
Solution 10 - DockerJoanComasFdzView Answer on Stackoverflow
Solution 11 - DockerkshitijView Answer on Stackoverflow