Internal container ports cannot be used if the same port is occupied by the host.
I’ve tried with two different images, nginx:latest and mysql:8.0 and both fails to bind to their default ports.
Im currently on docker version 4.18.0 (104112)
Windows 11 Pro 22H2 for x64-based Systems (KB5025239)
However, issue does not seem to be related to docker version. I have uninstalled Docker 4.18.0 and installed version 4.13.0. After several restarts the issue appeared again.
In my docker-compose file multiple services use default port 80, which they don’t expose to the host.
I had the same issue. All of my containers were working fine on Friday, but starting Saturday morning I couldn’t get any of them that were binding to port 80 internally to start without giving me similar exceptions. I was also getting the same errors when trying to run nginx.
Docker Desktop for Windows versions tested: 4.15.0, 4.16.3, 4.17.1, 4.18.0
Edition
Windows 11 Pro
Version
22H2
Installed on
10/28/2022
OS build
22621.1555
Experience
Windows Feature Experience Pack 1000.22640.1000.0
WSL Version:
1.2.0.0
What I had tried, none of which has allowed me to successfully start any containers that internally bind to port 80:
Clean/Purge data
Reset to factory defaults
Reinstalled docker desktop for Windows 4.18.0
Installed docker desktop back to 4.15.0
Restarted computer multiple times
Uninstalled Windows Update KB5025239 that had been applied late last week (took OS build back to 22621.1413 and experience pack to 1000.22639.1000.0)
wsl --update in Powershell, but result was The most recent version of Windows Subsystem for Linux is already installed.
I have another machine that is working fine. It’s currently running 4.18.0 and has the same WSL2 setup, the only difference is it’s running Windows Home.
Edition
Windows 11 Home
Version
22H2
Installed on
11/1/2022
OS build
22621.1555
Experience
Windows Feature Experience Pack 1000.22640.1000.0
WSL Version:
1.2.0.0
I ended up running: wsl --update --pre-release
Which updated my WSL version to 1.2.3.0. After that, I was able to run docker run nginx:latest and it started without the previous errors. I’m also able to start my other containers like before.
Interestingly enough, though, my Windows Home machine is still working without applying this update.
I think the error might be related to the fix noted in Release 1.2.1
This fixed issue for me as well, I had version WSL version 1.2.0 installed, which is now marked as pre-release.
Apparently, I believe this WSL version was briefly released and then demoted to pre-release.