Nginx 无法处理包含引号的全局指令:"daemon off;"
docker commit \
--change='EXPOSE 80' \
--change='CMD ["nginx", "-g", "daemon off;"]' \
${arr[0]} \
mine/nginx_final
执行表格
CMD ["foo"]被称为exec形式。一个进程将通过以下方式运行exec而不是通过外壳。数组中的每个元素都成为 exec 的参数。额外的"
引号被传递到 nginx:
CMD ["nginx", "-g", "\"daemon off;\""]
exec('nginx', '-g', '"daemon off;"')
使用 exec 形式已经传递了未更改的空间,因此您需要的是:
CMD ["nginx", "-g", "daemon off;"]
exec('nginx' '-g' 'daemon off;')
外壳形式
CMD foo被称为shell形式。带空格的全局指令参数需要在此处引用:
CMD nginx -g "daemon off;"
exec('sh', '-c', 'nginx -g "daemon off;"')
exec('nginx', '-g', 'daemon off;')
否则,解释命令的 shell 将在空格上分割参数并尝试并执行nginx
有 3 个参数:
CMD nginx -g daemon off;
exec('sh', '-c', 'nginx -g daemon off;')
exec('nginx', '-g', 'daemon', 'off;')