Solution to the docker mapping port error: 1. Switch to the root account; 2. Check the pid of the program running through the "netstat -nap" command; 3. Kill it through the "kill -9 2901 su u260517" command program and switch programs.
The operating environment of this tutorial: linux7.3 system, docker version 19.03, Dell G3 computer.
What should I do if there is an error in docker mapping port?
Docker mapping port error solution
1. Problem
docker run -itd --name hyperlpr_fastapi -p8668:8668 hyperlpr_fastapi:v1.0
When running the docker image, the port binding has been used:
docker: Error response from daemon: driver failed programming external connectivity on endpoint hyperlpr_fastapi (646d9ef9ad18cab0a5dd981d8fd2280f010d62c2b7c06dd1c17370fceeebfe86): Error starting userland proxy: listen tcp 0.0.0.0:8668: bind: address already in use.
2 , Solution
Switch to the root account, netstat -nap to check the pid of the program running, and look for the 8668 port. You can find that it is indeed occupied. Remember the PID
. Of course, you can also directly find a certain port. Check whether the port is occupied, command: netstat -nap | grep 8668
su root # 切换到root账户 netstat -nap | grep 8668 # 查看pid tcp 0 0 0.0.0.0:8668 0.0.0.0:* LISTEN 2901/python tcp 540778 0 127.0.0.1:54836 127.0.0.1:8668 CLOSE_WAIT 24527/python tcp 540778 0 127.0.0.1:54740 127.0.0.1:8668 CLOSE_WAIT 24527/python tcp 540778 0 127.0.0.1:54820 127.0.0.1:8668 CLOSE_WAIT 24527/python tcp 540778 0 127.0.0.1:54792 127.0.0.1:8668 CLOSE_WAIT 24527/python tcp 540778 0 127.0.0.1:54742 127.0.0.1:8668 CLOSE_WAIT 24527/python tcp 540778 0 127.0.0.1:54766 127.0.0.1:8668 CLOSE_WAIT 24527/python
kill PID, kill the process, here is kill 0
kill -9 2901 # 杀死程序 su u260517 # 切换到普通用户
Recommended study: "docker video tutorial》
The above is the detailed content of What to do if there is an error in docker mapping port. For more information, please follow other related articles on the PHP Chinese website!