Docker撰写,heroku,主机名链接和生产部署 [英] Docker compose, heroku, hostname links and production deployment

查看:88
本文介绍了Docker撰写,heroku,主机名链接和生产部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个简单的应用程序,由几个微服务(数据库,前端节点应用,用户服务等)组成,每个微服务都有自己的 Dockerfile ,并且 docker-compose.yml 文件将它们全部放置在本地部署环境中。因此,在 docker-compose up 时一切正常。

I currently have a simple app consisting of a few micro services (database, front-end node app, user services, etc.) each with its own Dockerfile, and a docker-compose.yml file to get them all up on a local deployment environment. So everything works fine doing docker-compose up.

对于生产,我一直在寻找Heroku(其他PaaS),不支持Docker Compose。

For production, I was looking for a Heroku (open to other PaaS), which do not support Docker Compose. Not specially nice, but could live with it for now.

问题是,在本地部署中使用Docker Compose,不同的服务会自动通过其主机名链接(如果mongo数据库服务称为 mydatabase,我可以在其他服务中执行 mongodb:// mydatabase /任何)。

The thing is that with Docker Compose on local deployment, the different services are linked via its hostname automatically (if the mongo database service is called "mydatabase", I can do mongodb://mydatabase/whatever within my other services).

问题是,Heroku上的那些链接会发生什么?在这种情况下,使不同的服务在开发和生产之间始终保持联系的最佳实践是什么?

So, the question is, what happens with those links on Heroku? What are the best practices to have the different services linked consistently between development and production in this case?

谢谢!

推荐答案

Docker compose创建了一个docker虚拟网络,该网络允许您使用容器名称作为主机名来连接容器。 Heroku不直接支持docker-compose,因为Docker compose确实旨在在您自己的计算机上进行
本地开发,而不是用于生产。

Docker compose creates a docker virtual network which allows you to connect the containers using the container name as a hostname. Heroku doesn't directly support docker-compose, as Docker compose is really intended for local development on your own machine and not for production.

用于生产Docker具有 Docker swarm ,它与Docker compose非常相似,但是适用于生产环境。您可以使用相同的docker-compose文件(在swarm中称为stackfile)部署在swarm上。
在docker swarm中,您可以使用相同的服务名称连接具有相同容器的容器,就像在docker-compose中一样。

For production Docker has Docker swarm, which is very similar to Docker compose, however is intended for production environments. You can use the same docker-compose file (called stackfile in swarm) to deploy on swarm. In docker swarm, you can connect the containers that you have using the same service name just like you would do in docker-compose.

Heroku支持Docker swarm通过 DockerHero插件,您可以使用它来连接Docker容器并在Heroku上运行

Heroku supports Docker swarm via the DockerHero add-on which you can use to to have your Docker container connected and running on Heroku.

这篇关于Docker撰写,heroku,主机名链接和生产部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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