Docker创建容器时报错 WARNING: IPv4 forwarding is disabled. Networking will not work.

创建nginx容器时报错:

[root@localhost nginx]# docker run -id --name=c_nginx \
> -p 80:80 \
> -v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf \
> -v $PWD/logs:/var/log/nginx \
> -v $PWD/html:/usr/share/nginx/html \
> nginx
WARNING: IPv4 forwarding is disabled. Networking will not work.
1c9b9bfee38fe849b2c18eba00dcd64dafc29b72b56b812d5261af07c96ee6c0

解决:

[root@localhost nginx]#  vi  /usr/lib/sysctl.d/00-system.conf

  添加代码:net.ipv4.ip_forward=1

重启:

[root@localhost nginx]# systemctl restart network

删除出错的容器重新创建即可。

[root@localhost nginx]# docker rm c_nginx
c_nginx
[root@localhost nginx]# docker run -id --name=c_nginx -p 80:80 -v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf -v $PWD/logs:/var/log/nginx -v $PWD/html:/usr/share/nginx/html nginx
db58952c37623807dc38fbd891df264aa48907b0837876194c2fbc985572ccb8

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值