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 bashCan Someone share the solution?
Thanks In Advance
5 Answers
You can check the existing port by running command
lsof -i tcp:81and
lsof -i tcp:3307if necessary you can kill that process with command
kill -9 [pid number]After that, you can try to re-run that docker command.
0Another 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-netand 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-imageThe 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 0So 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.
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,
Regards
0this 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 xThe order would tell indicate the conflicting containers
or use container network docker inspect network_nameto check whether the containers have the correct Ips