问题:
# 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]#