偶然间发现了这个问题,前几次发现每次重启centos都会连不上数据库,一看连接,发现自建数据库全没了,但是每次重启都要重新部署数据库很麻烦,于是搜素发现:docker 挂载进容器的文件修改后没有改变需要重启
所以每次都要重启才能让自建数据库能够访问
解决方法:
重启:
docker restart mysql
如果出现
Error response from daemon: Cannot restart container mysql: driver failed programming external connectivity on endpoint mysql (ae4380a7e05c4c0edf9094d5d6090dd4830e13d4bc76df80968528423f4919b2): Error starting userland proxy: listen tcp4 0.0.0.0:3306: bind: address already in use
netstat -ntpl |grep 3306 找到端口3306的任务进程
然后kill掉:
kill 20086,kill 20097
最后重启就可以了
docker restart [id]