使用docker时遇到的一些问题

①、centos下执行命令service network restart时,抛出主进程被占据的错

原因:从镜像创建容器时,通过以下命令创建

   docker run -itd --name centos-test centos  /bin/bash

   这时,进程(PID:1)会被/bin/bash占据。

对策:通过以下命令创建容器

   docker run -itd --name centos-test --privileged=true centos  /usr/sbin/init

②、Goland使用Docker插件,连接Docker失败

原因:没有开启Docker的远程访问

对策:如下图,Expose daemon on tcp://localhost:2375 without TLS处打勾

 

扫描二维码关注公众号,回复: 11379131 查看本文章

 ③、将要部署的项目创建容器时无法访问数据库

原因:docker是一个虚拟容器,其localhost与主机的localhost是不同的,不能互相访问。

对策:工程总配置文件的数据源要填写真实的IP地址。如果是开发环境的话,推荐使用【host.docker.internal】。这个DNS名称将被解析到主机的IP地址,省去了不断更换IP的麻烦。

猜你喜欢

转载自www.cnblogs.com/escctrl22222/p/13199483.html