1、报错如下:Error starting userland proxy: listen tcp4 0.0.0.0:3306: bind: address already in use.
docker.io/library/mysql:5.7 [root@CentOS7 ~]# docker run -p 3306:3306 --name mysql \ > -v /mydata/mysql/log:/var/log/mysql \ > -v /mydata/mysql/data:/var/lib/mysql \ > -v /mydata/mysql/conf:/etc/mysql \ > -e MYSQL_ROOT_PASSWORD=root \ > -d mysql:5.7 6da1e73bdbb0234153c1dc23e25479897cd075d254d39dfb2d9d934571bf00c7 docker: Error response from daemon: driver failed programming external connectivity on endpoint mysql (44413c44d35c9c05438197a65d380c06d9365031b931b1f59b7266d05980cabd): Error starting userland proxy: listen tcp4 0.0.0.0:3306: bind: address already in use.
2、使用netstat -tanlp
命令查询
可知:
原因是3306端口被PID=1454的进程号占用了,
3、kill 1454
再次查询,可看到3306端口已释放
4、重启systemctl restart docker
再次docker run 就成功
docker run -p 3306:3306 --name mysql \ -v /mydata/mysql/log:/var/log/mysql \ -v /mydata/mysql/data:/var/lib/mysql \ -v /mydata/mysql/conf:/etc/mysql \ -e MYSQL_ROOT_PASSWORD=root \ -d mysql:5.7