Running Docker for Windows, Error when exposing Ports

Søren Ullidtz picture Søren Ullidtz · Nov 18, 2016 · Viewed 39.8k times · Source

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.

Answer

biscuit314 picture biscuit314 · Dec 14, 2017

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/