经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 程序设计 » Docker » 查看文章
阿里云安装docker全过程
来源:jb51  时间:2023/4/6 8:42:30  对本文有异议

阿里云安装docker

记录阿里云搭建docker碰到的问题

阿里云搭建docker和本地有一点点区别,当安装成功后发现docker报错,如下:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

  1. /var/run/docker.sock is up
  2. time="2017-09-20T19:43:04.189684169+08:00" level=info msg="libcontainerd: new containerd process, pid: 17504"
  3. time="2017-09-20T19:43:05.195018039+08:00" level=info msg="[graphdriver] using prior storage driver: aufs"
  4. time="2017-09-20T19:43:05.202361669+08:00" level=info msg="Graph migration to content-addressability took 0.00 seconds"
  5. time="2017-09-20T19:43:05.202628053+08:00" level=warning msg="Your kernel does not support swap memory limit"
  6. time="2017-09-20T19:43:05.202683626+08:00" level=warning msg="Your kernel does not support cgroup rt period"
  7. time="2017-09-20T19:43:05.202699519+08:00" level=warning msg="Your kernel does not support cgroup rt runtime"
  8. time="2017-09-20T19:43:05.202842112+08:00" level=warning msg="mountpoint for pids not found"
  9. time="2017-09-20T19:43:05.203338693+08:00" level=info msg="Loading containers: start."
  10. Error starting daemon: Error initializing network controller: list bridge addresses failed: no available network
  11. /var/run/docker.sock is up
  12. time="2017-09-20T19:43:05.344214220+08:00" level=info msg="libcontainerd: new containerd process, pid: 17581"
  13. time="2017-09-20T19:43:06.349392877+08:00" level=info msg="[graphdriver] using prior storage driver: aufs"
  14. time="2017-09-20T19:43:06.354159926+08:00" level=info msg="Graph migration to content-addressability took 0.00 seconds"
  15. time="2017-09-20T19:43:06.354370574+08:00" level=warning msg="Your kernel does not support swap memory limit"
  16. time="2017-09-20T19:43:06.354434193+08:00" level=warning msg="Your kernel does not support cgroup rt period"
  17. time="2017-09-20T19:43:06.354450955+08:00" level=warning msg="Your kernel does not support cgroup rt runtime"
  18. time="2017-09-20T19:43:06.354525824+08:00" level=warning msg="mountpoint for pids not found"
  19. time="2017-09-20T19:43:06.355017538+08:00" level=info msg="Loading containers: start."
  20. Error starting daemon: Error initializing network controller: list bridge addresses failed: no available network
  21. /var/run/docker.sock is up

可以发现是网络有问题,然后用ifconfig查看,果然没有docker0这块虚拟网卡。

那么,在阿里云中为什么会启动失败呢?在Docker的源代码搜索上述错误信息,可以看出问题出在createBridge这个函数中。

该函数会检查下列IP段

  1. var addrs = []string{
  2. 172.17.42.1/16”,
  3. 10.0.42.1/16”,
  4. 10.1.42.1/16”,
  5. 10.42.42.1/16”,
  6. 172.16.42.1/24”,
  7. 172.16.43.1/24”,
  8. 172.16.44.1/24”,
  9. 10.0.42.1/24”,
  10. 10.0.43.1/24”,
  11. 192.168.42.1/24”,
  12. 192.168.43.1/24”,
  13. 192.168.44.1/24”,
  14. }

对于每个IP段,Docker会检查它是否和当前机器的域名服务器或路由表有重叠,如果有的话,就放弃该IP段。

让我们看看阿里云服务器的路由表

  1. root@iZ:/home/docker# route -n
  2. Kernel IP routing table
  3. Destination Gateway Genmask Flags Metric Ref Use Iface
  4. 0.0.0.0 114.55.11.247 0.0.0.0 UG 0 0 0 eth1
  5. 10.0.0.0 10.45.55.247 255.0.0.0 UG 0 0 0 eth0
  6. 10.45.52.0 0.0.0.0 255.255.252.0 U 0 0 0 eth0
  7. 100.64.0.0 10.45.55.247 255.192.0.0 UG 0 0 0 eth0
  8. 114.55.8.0 0.0.0.0 255.255.252.0 U 0 0 0 eth1
  9. 172.16.0.0 10.45.55.247 255.240.0.0 UG 0 0 0 eth0
  10. 192.168.0.0 10.45.55.247 255.255.0.0 UG 0 0 0 eth0

把路由表中不用的项删除,这样Docker就能找到能用的IP段了:

  1. sudo route del -net 172.16.0.0/12
  1. service docker start

好了问题解决

这时候可以用docker images查看镜像信息了:

  1. root@iZ:/home/docker# docker images
  2. REPOSITORY ? ? ? ? ?TAG ? ? ? ? ? ? ? ? IMAGE ID ? ? ? ? ? ?CREATED ? ? ? ? ? ? SIZE

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持w3xue。

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号