【故障排查】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

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

处理方法:

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搜出来的东西,作为参考思路吧。  

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

你可能感兴趣的:(故障排错,docker,kubernetes,nginx)