'port is already allocated' when attempting to run a container

Hi there,

When attempting to run the following command

docker run -d -p 4444:4444 --net grid --name selenium-hub selenium/hub:3.9.1-actinium

I get the following error…

C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: driver failed programming external connectivity on endpoint selenium-hub (0b468a1151ce2cbfa9c9be7e9f7230d636548da2bac0cd5f6f8c0473583df849): Error starting userland proxy: Bind for 0.0.0.0:4444 failed: port is already allocated.

I’ve tried the following to resolve this error…

  • The following command prompt returns nothing

  • C:\WINDOWS\system32>netstat -na | find "4444"

  • I have turned off experimental features

  • I have tried restarting the service via Settings -> Reset -> Restart Docker

  • I have tried doing a factory reset via Settings -> Reset -> Reset to factory default

  • Prior to running the command docker ps and docker ps -a returns nothing

  • PS C:\WINDOWS\system32> docker ps -a
    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

  • I’m running the commands in powershell as administrator

I’m at my wits end. What could be the issue here?

the docker container runs inside a Virtual machine on windows, so the windows ports are not the problem.
i do not know how to look inside the VM for something using port 4444 already

i just installed Oracle Virtualbox, which is the VM manager, and using that I can start the default vm, and
then from the docker terminal after doing docker run -d ubuntu
I can go to the vm console in virtualbox and docker ps and see the process/container running…

I’ve found the easiest way to get past this is with these commands, which detect stranded / orphaned parts of the docker ecosystem and clean them up:
docker system prune
docker volume prune
docker network prune

Take care when you are using these, don’t delete an important data volume or a container with unsaved changes, etc.

Docker for Windows has much more trouble with dangling, stranded connections and ports than docker in its native Linux.