今天测试Docker下配置一个nginx模板的镜像,装好nginx后,使用nginx -t进行检查,报错如下:
[root@a381c4c04132 yum.repos.d]# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol) nginx: configuration file /etc/nginx/nginx.conf test failed
检查配置文件:
server { listen 80 default_server; listen [::]:80 default_server; 根据错误提示分析,监听的方式可能不支持ipv6,于是将其注释掉 server { listen 80 default_server; # listen [::]:80 default_server; 然后再次检查配置: [root@a381c4c04132 yum.repos.d]# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful 没有报错了,问题解决