欢迎来到站长天空!

其它服务器

当前位置: 主页 > 服务器 > 其它服务器

阿里云安装docker全过程

时间:2025-12-13 08:30:04|栏目:其它服务器|点击:

目录
  • 阿里云安装docker
  • 该函数会检查下列IP段
  • 让我们看看阿里云服务器的路由表
  • 好了问题解决
  • 总结

阿里云安装docker

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

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

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

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

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

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

该函数会检查下列IP段

var addrs = []string{
“172.17.42.1/16”,
“10.0.42.1/16”,
“10.1.42.1/16”,
“10.42.42.1/16”,
“172.16.42.1/24”,
“172.16.43.1/24”,
“172.16.44.1/24”,
“10.0.42.1/24”,
“10.0.43.1/24”,
“192.168.42.1/24”,
“192.168.43.1/24”,
“192.168.44.1/24”,
}

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

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

root@iZ:/home/docker# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         114.55.11.247   0.0.0.0         UG    0      0        0 eth1
10.0.0.0        10.45.55.247    255.0.0.0       UG    0      0        0 eth0
10.45.52.0      0.0.0.0         255.255.252.0   U     0      0        0 eth0
100.64.0.0      10.45.55.247    255.192.0.0     UG    0      0        0 eth0
114.55.8.0      0.0.0.0         255.255.252.0   U     0      0        0 eth1
172.16.0.0      10.45.55.247    255.240.0.0     UG    0      0        0 eth0
192.168.0.0     10.45.55.247    255.255.0.0     UG    0      0        0 eth0

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

sudo route del -net 172.16.0.0/12
service docker start

好了问题解决

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

root@iZ:/home/docker# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

总结

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

上一篇:dockerfile的使用及使用dockerfile部署springboot项目的过程

栏    目:其它服务器

下一篇:docker安装minio无法访问的解决

本文标题:阿里云安装docker全过程

本文地址:https://zz.feitang.co/server/30518.html

广告投放 | 联系我们 | 版权申明

申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:257218569 | 邮箱:257218569@qq.com

Copyright © 2018-2025 站长天空 版权所有 Powered by EyouCms冀ICP备14023439号