Docker 之WARNING: IPv4 forwarding is disabled. Networking will not work. 解决办法
Posted 在奋斗的大道
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Docker 之WARNING: IPv4 forwarding is disabled. Networking will not work. 解决办法相关的知识,希望对你有一定的参考价值。
今天在本地安装完Docker ,然后启动abh1nav/dockerui 镜像,提示如下错误信息:
[root@localhost home]# docker run -d --privileged --name dockerui -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock abh1nav/dockerui
WARNING: IPv4 forwarding is disabled. Networking will not work.
97f024c55d667e6b2ea6efa0e019a1118358f396f3bc112adf2d77a7fc17a95a
造成此类问题原因:因Vmware 网桥配置没有开启转发功能,需要编辑/etc/sysctl.conf,添加net.ipv4.ip_forward=1即可。
MobaXterm 实际操作:
#配置转发
[root@localhost etc]# vim /etc/sysctl.conf
#重启网络服务,让配置生效
[root@localhost etc]# systemctl restart network
#查看是否成功,如果返回为“net.ipv4.ip_forward = 1”则表示成功
[root@localhost etc]# sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1
# 重新启动docker 服务
[root@localhost etc]# systemctl restart docker
# 查看docker 服务状态
[root@localhost etc]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since 三 2022-06-15 15:07:39 CST; 14s ago
Docs: https://docs.docker.com
Main PID: 89956 (dockerd)
Tasks: 19
Memory: 21.2M
CGroup: /system.slice/docker.service
├─89956 /usr/bin/dockerd
└─89963 docker-containerd --config /var/run/docker/containerd/containerd.toml
******
# 查看正在运行的容器
[root@localhost etc]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
# 查看所有运行的容器记录
[root@localhost etc]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
97f024c55d66 abh1nav/dockerui "./dockerui" 26 minutes ago Exited (2) About a minute ago dockerui
6c94b90f2ca7 centos "/bin/sh -c 'while t…" 3 hours ago Exited (137) 58 seconds ago friendly_noyce
c587f4387b92 c20987f18b13 "docker-entrypoint.s…" 4 hours ago Exited (1) 4 hours ago upbeat_rosalind
38f095df58c1 c20987f18b13 "docker-entrypoint.s…" 4 hours ago Exited (0) 4 hours ago youthful_clarke
a7963718f711 c20987f18b13 "docker-entrypoint.s…" 4 hours ago Exited (1) 4 hours ago friendly_kepler
# 重新启动指定容器
[root@localhost etc]# docker restart 97f024c55d66
97f024c55d66
# 查看正在运行的容器
[root@localhost etc]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
97f024c55d66 abh1nav/dockerui "./dockerui" 28 minutes ago Up 7 seconds 0.0.0.0:9000->9000/tcp dockerui
[root@localhost etc]#
核心指令片段:
vim /etc/sysctl.conf
#配置转发
net.ipv4.ip_forward=1
#重启服务,让配置生效
systemctl restart network
#查看是否成功,如果返回为“net.ipv4.ip_forward = 1”则表示成功
sysctl net.ipv4.ip_forward
以上是关于Docker 之WARNING: IPv4 forwarding is disabled. Networking will not work. 解决办法的主要内容,如果未能解决你的问题,请参考以下文章
docker WARNING: IPv4 forwarding is disabled 问题解决
docker 错误 WARNING: IPv4 forwarding is disabled. Networking will not work.
Docker报错 WARNING: IPv4 forwarding is disabled. Networking will not work.