Running Docker for Windows, Error when exposing Ports

雨燕双飞 提交于 2019-12-02 16:29:56

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.

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/

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

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.

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

Abhishek Jain

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.....

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.

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.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!