安装完docker后测试是否成功安装,拉取hello-world镜像进行测试
报以下错误
- Unable to find image 'hello-world:latest' locally
- docker: Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
- See 'docker run --help'.
复制代码 Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
See 'docker run --help'.
刚开始以为是权限问题
直接把daemon.json文件加权限 ,照旧报错
[root@localhost docker]# chmod 777 daemon.json
[root@localhost docker]# sudo systemctl daemon-reload
[root@localhost docker]# sudo systemctl restart docker
[root@localhost docker]# docker run hello-world
Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get "https://registry-1.docker.io/v2/": dial tcp 108.160.166.137:443: i/o timeout (Client.Timeout exceeded while awaiting headers).
See 'docker run --help'.
在网上搜了几种方法,基本都是镜像源的问题,我这里已经添加了阿里云的镜像源,照旧会报这个错误,尝试使用其他镜像源
[root@localhost docker]# cat daemon.json
{
"registry-mirrors": [
"https://do.nark.eu.org",
"https://dc.j8.work",
"https://docker.m.daocloud.io",
"https://dockerproxy.com",
"https://docker.mirrors.ustc.edu.cn",
"https://docker.nju.edu.cn"
]
}
更改完镜像源后,重启docker进行重新拉取hello-world,发现照旧报错
此时进行docker info进行查看,发现有个报错
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
于是进行解决这个报错
- [root@localhost docker]# docker info
- Client: Docker Engine - Community
- Version: 26.1.4
- Context: default
- Debug Mode: false
- Plugins:
- buildx: Docker Buildx (Docker Inc.)
- Version: v0.14.1
- Path: /usr/libexec/docker/cli-plugins/docker-buildx
- compose: Docker Compose (Docker Inc.)
- Version: v2.27.1
- Path: /usr/libexec/docker/cli-plugins/docker-compose
- Server:
- Containers: 0
- Running: 0
- Paused: 0
- Stopped: 0
- Images: 0
- Server Version: 26.1.4
- Storage Driver: overlay2
- Backing Filesystem: xfs
- Supports d_type: true
- Using metacopy: false
- Native Overlay Diff: true
- userxattr: false
- Logging Driver: json-file
- Cgroup Driver: cgroupfs
- Cgroup Version: 1
- Plugins:
- Volume: local
- Network: bridge host ipvlan macvlan null overlay
- Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
- Swarm: inactive
- Runtimes: io.containerd.runc.v2 runc
- Default Runtime: runc
- Init Binary: docker-init
- containerd version: d2d58213f83a351ca8f528a95fbd145f5654e957
- runc version: v1.1.12-0-g51d5e94
- init version: de40ad0
- Security Options:
- seccomp
- Profile: builtin
- Kernel Version: 3.10.0-693.el7.x86_64
- Operating System: CentOS Linux 7 (Core)
- OSType: linux
- Architecture: x86_64
- CPUs: 4
- Total Memory: 7.781GiB
- Name: localhost.localdomain
- ID: ac6faaa2-00de-445a-b6e0-7fba22e5a500
- Docker Root Dir: /var/lib/docker
- Debug Mode: false
- Experimental: false
- Insecure Registries:
- 127.0.0.0/8
- Registry Mirrors:
- https://do.nark.eu.org/
- https://dc.j8.work/
- https://docker.m.daocloud.io/
- https://dockerproxy.com/
- https://docker.mirrors.ustc.edu.cn/
- https://docker.nju.edu.cn/
- Live Restore Enabled: false
- WARNING: bridge-nf-call-iptables is disabled
- WARNING: bridge-nf-call-ip6tables is disabled
复制代码 做一下修改和配置来解决这个问题。
由于将linux体系作为路由或者VPN服务就必须要开启IP转发功能。当linux主机有多个网卡时一个网卡收到的信息是否能够通报给其他网卡,假如设置成1的话可以进行数据包转发,可以实现VxLAN等功能,不开启会导致docker摆设应用无法访问。
1.开启包转发功能和修改内核参数
br_netfilter模块用于将桥接流量转发至iptables链,br_netfilter内核参数则需要开启转发。
执行以下命令:
[root@localhost docker]# modprobe br_netfilter
[root@localhost docker]# cat > /etc/sysctl.d/docker.conf <<EOF
> net.bridge.bridge-nf-call-ip6tables=1
> net.bridge.bridge-nf-call-iptables = 1
> net.ipv4.ip_forward = 1
> EOF
重新加载使配置生效
[root@localhost docker]# sysctl -p /etc/sysctl.d/docker.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
查看配置是否生效
[root@localhost docker]# lsmod | grep br_netfilter
br_netfilter 22209 0
bridge 136173 1 br_netfilter
当重启Docker后以上模块配置会失效,为确保下次重启后依然生效,可设置开机主动加载模块的脚本。
首先,在/etc/目录下新建rc.sysinit文件,输入命令:vim /etc/rc.sysinit,然后再编辑器界面输入一下命令:
[root@localhost docker]# vim /etc/rc.sysinit
#!/bin/bash
for file in /etc/sysconfig/modules/*.modules ; do
[ -x $file ] && $file
done
在/etc/sysconfig/modules/目录下新建文件br_netfilter.modules
[root@localhost docker]# cd /etc/sysconfig/modules/
[root@localhost modules]# ls
[root@localhost modules]# vim br_netfilter.modules
modprobe be_netfilter
给 br_netfilter.modules文件授权
[root@localhost modules]# chmod 755 /etc/sysconfig/modules/br_netfilter.modules
[root@localhost modules]# systemctl restart docker
再次docker info 发现报错信息已经没了
再次docker run hello-world进行拉取镜像,发现解决了
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |