Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Docker for Windows, Error when exposing Ports

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.

like image 922
Søren Ullidtz Avatar asked Nov 18 '16 03:11

Søren Ullidtz


People also ask

Can we expose a port on running container?

You cannot do this via Docker, but you can access the container's un-exposed port from the host machine.

How do I know if my Docker port is exposed?

Exposed ports are visible when you list your containers with docker ps . They'll show up in the PORTS column, even though they won't actually be accessible outside the container. This gives you a simple way of checking which ports the software inside a container is listening on.

Can I expose multiple ports Docker?

In your Dockerfile , you can use the verb EXPOSE to expose multiple ports.


2 Answers

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/

like image 172
biscuit314 Avatar answered Sep 23 '22 15:09

biscuit314


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

like image 37
Phonolog Avatar answered Sep 19 '22 15:09

Phonolog