docker: Error response from daemon: Address already in use

I am creating a container with following command

docker run -it -p 81:80 -p 3307:3306 --net mynet123 --ip 172.18.0.22 -v /opt/lampp/htdocs:/var/www/html lamp-setia bash

Can Someone share the solution?

Thanks In Advance

5 Answers

You can check the existing port by running command

lsof -i tcp:81

and

lsof -i tcp:3307

if necessary you can kill that process with command

kill -9 [pid number]

After that, you can try to re-run that docker command.

0

Another scenario that have the exact same error is when the IP address is in use. In my setup, I had a network setup like this:

docker network create --subnet 172.28.5.0/24 cluster-test-net

and I was trying to start my docker container as below:

docker run -d --name wildfly1 --ip 172.28.5.1 -h wildfly1 -p 8080:8080 -p 9990:9990 --network=cluster-test-net wildfly-cluster-image

The reason that I got the error was that docker had already assigned the IP address 172.28.5.1 to the host itself. I noticed that when I ran ifconfig on my host and found this row in the result:

br-bb89994f6a73: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 172.28.5.1 netmask 255.255.255.0 broadcast 172.28.5.255 inet6 fe80::42:a2ff:fecd:81e9 prefixlen 64 scopeid 0x20<link> ether 02:42:a2:cd:81:e9 txqueuelen 0 (Ethernet) RX packets 4394 bytes 4695729 (4.6 MB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 2342 bytes 175071 (175.0 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

So I just fixed it by choosing a different IP address for my docker container:

docker run -d --name wildfly1 --ip 172.28.5.10 -h wildfly1 -p 8080:8080 -p 9990:9990 --network=cluster-test-net wildfly-cluster-image

Seems that some other process is already holding the host ports that you are trying to map with the container. You may consider using netstat -aon to find out if there is/are existing processses that are holding ports 81 and 3307 on the docker host.

0

The port you have given in the docker run command might be assigned to some other process. Please find what is running over there. If something unimportant kill it. Or you can proceed with available ports.

Please find a snapshot below for reference,enter image description here

Regards

0

this means another container is taking the container's IP. Stop all containers and then start your container. then start your container :

docker stop x
docker network connect --ip 172.24.0.4 yournetwork y
docker start y
docker start x

The order would tell indicate the conflicting containers

or use container network docker inspect network_nameto check whether the containers have the correct Ips

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like