K8S 部署nginx 自定义命令参数指定配置文件位置启动失败 YAML 现象 解决

containers:
  - name: nginx-test
    image: 'nginx:alpine-perl'
    command:
      - nginx
    args:
      - '-g daemon off;'
      - '-c /xxx/nginx.conf'

现象

启动报异常

nginx: [emerg] open() “/etc/nginx/ /xxx/nginx.conf” failed (2: No such file or directory)

解决

修改yaml

containers:
  - name: nginx-test
    image: 'nginx:alpine-perl'
    command:
      - nginx
    args:
      - '-g daemon off;'
      - '-c'
      - /xxx/nginx.conf