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

查看:48
本文介绍了Docker compose、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.

对于生产,我正在寻找不支持 Docker Compose 的 Heroku(对其他 PaaS 开放).不是特别好,但现在可以忍受.

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/whatevercode> 在我的其他服务中).

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 通过 DockerHero 附加组件 支持 Docker swarm,您可以使用它来让您的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 compose、heroku、主机名链接和生产部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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