我正在尝试在 docker 容器(ECS - Fargate)内运行 django 应用程序
但是,我无法弄清楚如何在Command任务定义部分运行多个命令,目前它的配置如下
但是我的容器继续运行STOPPING,我什至看不到 CloudWatch 中的日志
如何让它正确执行?,任何帮助都非常感谢
我正在尝试在 docker 容器(ECS - Fargate)内运行 django 应用程序
但是,我无法弄清楚如何在Command任务定义部分运行多个命令,目前它的配置如下
但是我的容器继续运行STOPPING,我什至看不到 CloudWatch 中的日志
如何让它正确执行?,任何帮助都非常感谢
在你的情况下,我会通过使用/bin/sh -c尽管入口点来做到这一点:
/bin/sh -c "python manage.py ... <and the rest>"
这也是官方 AWS ECS教程中的做法:
            "entryPoint": [
                "sh",
                "-c"
            ],
            "command": [
                "/bin/sh -c \"echo '<html> <head> <title>Amazon ECS Sample App</title> <style>body {margin-top: 40px; background-color: #333;} </style> </head><body> <div style=color:white;text-align:center> <h1>Amazon ECS Sample App</h1> <h2>Congratulations!</h2> <p>Your application is now running on a container in Amazon ECS.</p> </div></body></html>' >  /usr/local/apache2/htdocs/index.html && httpd-foreground\""
            ]
这对我使用aws ecs run-task命令有用。
{
  "command": [
    "bin/sh", "-c", "echo 'Hello' && echo ' alien ' && echo 'World'"
  ]
}
该命令只需拆分为bin/sh和-c其余命令可以与 连接在一起&&。
问题在于其中一项服务rk-nginx
这是以前的nginx.conf
upstream gunicorn {
    # docker will automatically resolve this to the correct address
    # because we use the same name as the service: "django"
    server django:8000;
}
但是django关键字给了我问题(我认为这是 ecs 如何处理网络的一部分),我只是将其更改为
upstream gunicorn {
    server localhost:8000;
}