【发布时间】:2017-09-28 12:59:50
【问题描述】:
我的 Dockerfile 中有以下内容:
ENTRYPOINT ["/bin/wait-for", "wordpress:9000", "--"]
CMD nginx -g "daemon off;"
结果:
nginx_1 | Attempting...
nginx_1 | Command: /bin/sh -c nginx -g "daemon off;"
nginx_1 | Attempting to execute command:
nginx_1 | /bin/sh -c nginx -g "daemon off;"
ayurved_nginx_1 exited with code 0
我猜问题是引号......
我怎样才能让它执行/bin/wait-for wordpress:9000 -- nginx -g "daemon off;"?
【问题讨论】:
-
如果使用
CMD的JSON形式呢?CMD ["nginx", "-g", "\"daemon off;\""] -
也不行
-
这应该可以工作我猜
CMD ["nginx -g 'daemon off;'"] -
解释发生了什么:
/bin/sh -c nginx -g "daemon off;"正在运行nginx作为脚本,$0中的-g和$1中的daemon off。但是脚本nginx既不看$0或$1。 -
最好的选择是根本没有
/bin/sh -c。如果您没有 shell,那么您的 argv 的其余部分将完全正确。
标签: docker dockerfile