问题:
# docker run -it -p 30001:22 --name=centos-ssh centos /bin/bash WARNING: IPv4 forwarding is disabled. Networking will not work.
解决办法
[root@localhost sysctl.d]# pwd /usr/lib/sysctl.d [root@localhost sysctl.d]# ll total 20 -rw-r--r--. 1 root root 315 Mar 25 18:31 00-system.conf -rw-r--r--. 1 root root 1810 Oct 31 03:36 10-default-yama-scope.conf -rw-r--r--. 1 root root 1205 Oct 31 07:31 50-default.conf -rw-r--r--. 1 root root 499 Oct 31 08:16 60-libvirtd.conf -rw-r--r--. 1 root root 23 Mar 12 17:56 99-docker.conf [root@localhost sysctl.d]# vi 00-system.conf # Kernel sysctl configuration file # # For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and # sysctl.conf(5) for more details. # Disable netfilter on bridges. net.bridge.bridge-nf-call-ip6tables = 0 net.bridge.bridge-nf-call-iptables = 0 net.bridge.bridge-nf-call-arptables = 0 net.ipv4.ip_forward=1 ####添加此句
重启网络
[root@localhost sysctl.d]# service network restart
Restarting network (via systemctl): [ OK ]
[root@localhost sysctl.d]#
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步