创建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