【故障排查】k8s/docker容器启动后报错 nginx: [emerg] unexpected end of parameter, expecting “;“ in command line

报错信息:

#k8s
kubectl apply -f 05-wp-dp.yaml
[root@master01 wordpressDemo]# kubectl logs wordpress-dp-74dd966d9-q25pf 
nginx: [emerg] unexpected end of parameter, expecting ";" in command line

#docker
docker run -itd harbor.oldxu.net/base/wordpress:v6.0
[root@node4 wordpress]# docker logs 09a384e7305e
nginx: [emerg] unexpected end of parameter, expecting ";" in command line

在这里插入图片描述

处理方法:

entrypoint.sh的nginx启动方式nginx -g "daemon off", 少写了 ; 号 ,将;号补上,重新docker build 即可

[root@node4 wordpress]# ls
Dockerfile     index.php    readme.html      wp-admin            wp-comments-post.php  wp-config-sample.php  wp-cron.php  wp-links-opml.php  wp-login.php  wp-settings.php  wp-trackback.php
entrypoint.sh  license.txt  wp-activate.php  wp-blog-header.php  wp-config.php         wp-content            wp-includes  wp-load.php        wp-mail.php   wp-signup.php    xmlrpc.php

#下面的是原本错误写法:
[root@node4 wordpress]# cat entrypoint.sh 
Wordpress_File=/usr/share/nginx/html/wp-config.php

#启动php /nginx
php-fpm && \
nginx -g "daemon off"

其他 & 排查过程 & 反思

Dockerfile的内容没错,entrypoint.sh文件有问题。

nginx: [emerg] unexpected end of parameter, expecting ";" in command line
没真正理解这个报错含义。开始以为是配置文件少;号。 实际的定语 in command line ,期待;号。 (英文理解有待提升)
nginx -g "daemon off"  --改成--> nginx -g "daemon off;" 

单独部署nginx服务,使用nginx -t 检查blog.oldxu.net.conf的语法是OK的。将其configmap化,dp调用他。 或者dp中注释它还是报这错。
然后dp换了oldxu的镜像(oldxu3957/wordpress:v6.0),能正常运行,也说明cm是没问题的。 而问题所在是dockerfile构建出来的镜像运行有问题。
实际上conf文件少;号的报错信息如下:

[root@node-2 conf.d]# nginx -t
### 一、少;号时的报错,他会具体举出 报错的文件+行号
nginx: [emerg] invalid parameter "server_name" in /etc/nginx/conf.d/blog.oldxu.net.conf:3
nginx: configuration file /etc/nginx/nginx.conf test failed

[root@node-2 conf.d]# vim blog.oldxu.net.conf 
[root@node-2 conf.d]# nginx -t
### 二、少;号时的报错,他会具体举出 报错的文件+行号
nginx: [emerg] invalid number of arguments in "fastcgi_param" directive in /etc/nginx/conf.d/blog.oldxu.net.conf:13
nginx: configuration file /etc/nginx/nginx.conf test failed


[root@node-2 conf.d]# vim blog.oldxu.net.conf 
[root@node-2 conf.d]# 
[root@node-2 conf.d]# nginx -t
### 三、少}号时的报错
nginx: [emerg] unexpected end of file, expecting "}" in /etc/nginx/conf.d/blog.oldxu.net.conf:16
nginx: configuration file /etc/nginx/nginx.conf test failed

反思

粗心了,漏写 抄错。。。
百度和gpt搜出来的东西,作为参考思路吧。  

在这里插入图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值