Akshay
Akshay

Reputation: 11

Docker toolbox on windows 10. Bind for 0.0.0.0:8081 failed: port is already allocated error

I have setup docker toolbox on windows 10. While building the project I encountered the following error :- Bind for 0.0.0.0:8081 failed: port is already allocated ? The sudo service docker restart command isn't working. Please provide me a solution for the same.

Upvotes: 1

Views: 843

Answers (2)

Leonid Pavlov
Leonid Pavlov

Reputation: 819

Commonly if this error happens, I restarting my winnat with commands:

$ net stop winnat

// build your project

$ net start winnat

If that doesnt help. I restart whole docker with commands:

wsl --unregister docker-desktop
wsl --unregister docker-desktop-data

Then docker offers to restart docker-service.

Upvotes: 1

Roman
Roman

Reputation: 21883

Generally speaking, you need to stop running the current container. For that you are going to know current CONTAINER ID:

$ docker container ls

You get something like:

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                  NAMES
97a32e8928ef        friendlyhello       "python app.py"     51 seconds ago      Up 50 seconds       0.0.0.0:4000->80/tcp   romantic_tesla   

Then you stop the container by:

$ docker stop 97a32e8928ef

Finally, you try to do what you wanted to do, for example:

$ docker run -p 4000:80 friendlyhello

Upvotes: 1

Related Questions