简体   繁体   English

Elastic Beanstalk 上的 Docker + Django

[英]Docker + Django on Elastic Beanstalk

I have a Django project.我有一个 Django 项目。 I am considering adding Docker to it before deploying to Elastic Beanstalk.我正在考虑在部署到 Elastic Beanstalk 之前将 Docker 添加到其中。 I am very new to Django and Docker and want to know what are the benefits of using Docker when deploying a Django app to Elastic Beanstalk. I am very new to Django and Docker and want to know what are the benefits of using Docker when deploying a Django app to Elastic Beanstalk. Thanks!谢谢!

The general benefits of using Docker in EB, as compared to regular Python EB environment portability and reproducibility .与常规 Python EB 环境可移植性和再现性相比,在 EB 中使用 Docker 的一般优势。

If you bundle your django app as Docker container, you know that you your development environment will be exactly same as your production one.如果您将 django 应用程序捆绑为 Docker 容器,您就会知道您的开发环境将与您的生产环境完全相同 All the dependencies, package versions, tools will be same in the container, regardless if it runs on your local workstation, home laptop or on EB platform.所有依赖项,package 版本,容器中的工具都将相同,无论它是在本地工作站、家用笔记本电脑还是在 EB 平台上运行。

However, when you use regular Python platform, the portability and reproducibility can be difficult to guarantee.但是,当您使用常规的 Python 平台时,可移植性和再现性可能难以保证。 The current Python platform is based on Amazon Linux 2 .当前的 Python 平台基于Amazon Linux 2 So the question is, is your development environment at home or work exactly same?那么问题来了,你的开发环境是在家里还是在工作中完全一样? Usually this is not the case, which often leads to issues in the vain of "It works on my local ubuntu workstation, but not on EB".通常情况并非如此,这通常会导致“它在我的本地 ubuntu 工作站上工作,但在 EB 上不工作”的问题。

Also, one day you may decide to migrate your app out of EB or even AWS.此外,有一天您可能决定将您的应用程序迁移出 EB 甚至 AWS。 It will be much easier to do that when using docker.使用 docker 时,这样做会容易得多。 This is because EB is a custom product from AWS, not available in other could providers with its own settings and requirements.这是因为 EB 是 AWS 的定制产品,在其他具有自己的设置和要求的供应商中不可用。

EB supports two types of docker-based environments: EB 支持两种基于 docker 的环境:

Depending on your requirements, you would have to use one of them.根据您的要求,您将不得不使用其中之一。 Each of them has its own use-cases, which I think are out of the scope to discuss for this question.他们每个人都有自己的用例,我认为这些用例不在 scope 中讨论这个问题。

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

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