如何解决在Amazon ECS任务中指定入口点时出现问题
我正在尝试复制有关在Amazon ECS环境中的容器中运行Nginx和Certbot的建议。我一直遵循的建议可以在here中找到。这非常好,但是我正在为确保将来更新证书而进行的最后一步。例如,对于Nginx推荐的命令是:
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
在本地容器上可以工作,但是ECS需要以字符串数组格式进行操作,因此我使用了以下命令(在本地工作):
command: ["/bin/sh","-c","while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\""]
我将其添加到ECS控制台。但是,该任务无法启动,并且在输出中我得到了:
/bin/sh: 1: wait: Illegal number: 1{!}
nginx: invalid option: "off"
/bin/sh: 1: ": not found
任务JSON中的命令如下:
"command": [
"/bin/sh","while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \\\"daemon off;\\\""
],
这似乎无法正确解释,但我不确定如何引用(或转义)它才能正常工作?
解决方法
您可以尝试“命令我的版本”吗? 我相信您遇到了问题,因为您用'
替换了'command original: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
command your version: ["/bin/sh","-c","while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\""]
command my version: ["/bin/sh",'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"']
,
最后找到了满足JSON
和sh
引用需求的魔术组合,并修复了途中的脚本错误。最后的立场是在ECS控制台中输入以下内容:
/bin/sh,-c,while :; do sleep 6h & wait $!; nginx -s reload; done & nginx -g 'daemon off'
这导致JSON
如下所示:
"command": [
"sh","while :; do sleep 6h & wait $!; nginx -s reload; done & nginx -g 'daemon off;'"
],
出于某种原因,在ECS环境中,我能够使用对子PID $!
的更直接引用,而不是SS{!}
世界所需的更晦涩的docker-compose
。 / p>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。