Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to kill used port of docker

I am trying to run one docker image and it is saying address already in use

 driver failed programming external connectivity on endpoint jovial_saha (c79c98cbcef6340cd7867571278f401c9cbea1fd7137a39fe5d7de1c454d4e6e): Error starting userland proxy: listen tcp 0.0.0.0:9042: bind: address already in use.

However i have deleted all containers and images and then even if i call to run my image by

docker run -d -p 9042:9042 myimage . i get above error. what  should i do ?
like image 739
Karn_way Avatar asked May 15 '16 02:05

Karn_way


People also ask

How to kill a docker container that occupies a port?

You can give the container a known name with the docker run --name option, and use that name in the docker stop and docker rm commands (and elsewhere) without having to look up the container ID. You could use the following command to kill the running container that occupies a given port:

What is the difference between Docker kill and Docker stop?

docker kill immediately stops/kills the running containers (by sending the SIGKILL signal to the main process inside the container). You can also choose to gracefully stop all running containers by using the docker stop command instead of docker kill. Hope you found this post useful. It was published about 4 hours ago.

What is port mapping in Docker?

Port mapping makes the processes inside the container available from the outside. While running a new Docker container, we can assign the port mapping in the docker run command using the -p option: The above command launches an httpd container and maps the host’s port 81 to port 80 inside that container.

How to get the Container ID in Docker stop command?

For docker stop command we have to pass container id in an automation script that i am not able to do You can give the container a known name with the docker run --name option, and use that name in the docker stop and docker rm commands (and elsewhere) without having to look up the container ID.


1 Answers

To expand on Robert Moskal's answer, you'll need to kill whatever's already on that port:

  • kill all the containers again
  • if you're on Linux, kill the process running on your port with fuser -k 9042/tcp
  • if above steps don't work, reboot your computer and try again.

Happy hunting!

like image 157
johntellsall Avatar answered Sep 19 '22 11:09

johntellsall