在 Google App Engine 中使用 Docker compose [英] Using Docker compose within Google App Engine

查看:20
本文介绍了在 Google App Engine 中使用 Docker compose的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在试验 Google App Engine 柔性环境,特别是允许您构建自定义运行时 通过提供 Dockerfile.

I am currently experimenting with the Google App Engine flexible environment, especially the feature allowing you to build custom runtimes by providing a Dockerfile.

Docker 提供了一个非常棒的特性,叫做 docker-compose,用于定义和运行多容器 Docker 应用程序.

Docker provides a really nice feature called docker-compose for defining and running multi-container Docker applications.

现在的问题是,有没有办法在 GAE 中使用 docker-compose 的强大功能?如果答案是否定的,那么在使用 Docker 的 GAE 灵活环境中部署多容器应用程序(例如 Nginx + PHP-FPM + RabbitMQ + Elasticsearch + Redis + MongoDB,...)的最佳方法是什么?

Now the question is, is there any way one can use the power of docker-compose within GAE? If the answer is no, what would be the best approach for deploying a multi-container application (for instance Nginx + PHP-FPM + RabbitMQ + Elasticsearch + Redis + MongoDB, ...) within GAE flexible environment using Docker?

推荐答案

目前无法使用 docker-compose 在单个 App Engine 实例中拥有多个应用程序容器.然而,这似乎是设计使然.

It is not possible at this time to use docker-compose to have multiple application containers within a single App Engine instance. This does seem however to be by design.

如果您想拥有多个应用程序容器,则需要将它们部署为单独的 App Engine 服务.每个服务实例仍然只有一个应用程序容器,但每个服务可能有多个实例.这将为您提供独立扩展每个应用程序组件的灵活性.此外,如果容器中的应用程序挂起,也不会影响其他服务,因为它们将驻留在不同的 VM 中.将每个组件部署为单独的服务的另一个好处是不需要为每个服务使用灵活的环境.对于一些非常小的任务,例如 API 后端或提供相对缓慢变化的 Web 内容,标准环境可能就足够了,并且在低资源水平下可能会更便宜.

If you would like to have multiple application containers, you would need to deploy them as separate App Engine services. There would still only be a single application container per service instance but there could be multiple instances of each service. This would grant you the flexibility you seek of scaling each application component independently. In addition, if the application in a container were to hang, it could not affect other services as they would reside in different VMs. An added benefit of deploying each component as a separate service is that one need not use the flexible environment for every service. For some very small tasks such as API backends or serving relatively slow-changing web content, the standard environment may suffice and may be less expensive at low resource levels.

由于您的评论中提到了获取实例 IP,我认为您可能会发现服务间通信很有用.我不确定您希望使用 VM 实例 IP 的原因是什么,但典型的用例可能是在实例或服务之间进行通信.要在没有实例 IP 的情况下执行此操作,最好的办法是使用适当的 url 从一个服务向另一个服务发出 HTTP 请求.如果您有一个名为 web 的服务和一个名为 api 的服务,web 服务可以向 api.mycustomdomain.com<发出请求/code> 托管您的应用程序,api 服务将收到带有 X-Appengine-Inbound-Appid 标头,使用您的项目 ID 指定.这可以作为一种将请求识别为来自您自己的应用程序的方式.

Since one of your comments mentions getting instance IPs, I thought you might find inter-service communication useful. I'm not certain for what reason you wish to use VM instance IPs but a typical use case might be to communicate between instances or services. To do this without instance IPs, your best bet is to issue HTTP request from one service to another simply using the appropriate url. If you have a service called web and one called api, the web service can issue a request to api.mycustomdomain.com where your application is hosted and the api service will receive a request with the X-Appengine-Inbound-Appid header specified with your project ID. This can serve as a way a identifying the request as coming from your own application.

您提到了许多应用程序示例,包括 NGinx、PHP-FPM、RabbitMQ 等.使用 App Engine 使用 自定义运行时,您可以部署任何容器来处理流量,只要它响应来自端口 8080 的请求.请记住,应用程序的主要目的是提供响应.实例应设计为快速启动和关闭,以实现水平可扩展.它们不应用于存储任何应用程序数据.使用 Cloud SQLCloud Datastore、BigQuery 或您自己的 Redis 实例在 Compute Engine 上运行.

You mention many examples of applications including NGinx, PHP-FPM, RabbitMQ, etc.. With App Engine using custom runtimes, you can deploy any container to handle traffic as long as it responds to requests from port 8080. Keep in mind that the primary purpose of the application is to serve responses. The instances should be designed to start up and shut down quickly to be horizontally scalable. They should not be used to store any application data. That should remain outside of App Engine using tools like Cloud SQL, Cloud Datastore, BigQuery or your own Redis instance running on Compute Engine.

我希望这能澄清一些事情并回答您的问题.

I hope this clarifies a few things and answers your questions.

这篇关于在 Google App Engine 中使用 Docker compose的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆