简体   繁体   English

Python 3.4 Docker容器中的AWS Elastic Beanstalk container_commands

[英]AWS Elastic Beanstalk container_commands in Python 3.4 Docker Container

I have a Django 1.6 application running on Python 3.4 that I'd like to deploy on AWS Elastic Beanstalk , so I've selected “Preconfigured - Docker/Python” (ie, Python 3.4) as my configuration but deployments fail on the container_command to run django-admin.py . 我有一个要在Python 3.4上运行的Django 1.6应用程序,并且希望在AWS Elastic Beanstalk上进行部署,因此我选择了“预配置-Docker / Python”(即Python 3.4)作为配置,但是在container_command上部署失败运行django-admin.py The same placeholder app bundle runs as expected on the “Preconfigured/Python” configuration (ie, Python 2.7) without error. 相同的占位符应用程序捆绑包在“预配置/ Python”配置(即Python 2.7)上按预期运行,没有错误。

According to the documentation .ebextension config container_commands are run after the application and web server have been set up and the application version file has been extracted, but before the application is deployed. 根据文档, .ebextension config container_commands在设置了应用程序和Web服务器并提取了应用程序版本文件之后,但在部署应用程序之前运行。 That appears to be the case for the Python 2.7 container but not the Python 3.4 Docker container. Python 2.7容器似乎是这种情况,而Python 3.4 Docker容器则并非如此。

To test the theory, I added a script to my bundle to peek at the environment and executed it as a container_command . 为了验证该理论,我向捆绑包中添加了一个脚本来查看环境,并将其作为container_command执行。 The Python 2.7 container uses Python 2.7, has pip packages installed from requirements.txt , and finds django-admin.py as expected. Python 2.7容器使用Python 2.7,并从requirements.txt安装了pip包, django-admin.py预期方式找到django-admin.py The Python 3.4 Docker container, however, uses Python 2.6 during the container_command phase and thus doesn't have the environment set up to find django-admin.py or installed pip packages. 但是,Python 3.4 Docker容器在container_command阶段使用Python 2.6,因此没有设置环境来查找django-admin.py或已安装的pip软件包。

How can I get the the Preconfigured - Docker/Python (3.4) container to execute container_commands in the intended environment? 如何获得预配置的Docker / Python(3.4)容器以在预期的环境中执行container_commands Is there a step missing to activate the container and/or it's virtualenv before triggering container_commands ? 在触发container_commands之前,是否缺少激活容器和/或virtualenv的步骤?

AWS Support pointed me to adding a custom Dockerfile. AWS支持人员指示我添加自定义Dockerfile。 I used my Dockerfile's ENTRYPOINT to override the default from the base image so I could slip in my own script to trigger the syncdb command. 我使用了Dockerfile的ENTRYPOINT来覆盖基础映像中的默认值,因此我可以穿上自己的脚本来触发syncdb命令。

ref: https://forums.aws.amazon.com/message.jspa?messageID=595630 参考: https : //forums.aws.amazon.com/message.jspa? messageID =595630

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM