Docker 捆绑包和 docker-compose 之间有什么区别?

What is the different between Docker bundles and docker-compose?

Docker 1.12引入了bundle的新概念。描述一组服务的新文件格式。

我的应用程序已使用 docker-compose 部署。我的每个环境都有一个 docker-compose.yml,我可以使用 docker-compose up.

快速部署我的应用程序

根据我对 this post 的理解,Docker 捆绑包 只是内置 Docker 做同样事情的新方法正如 docker-compose 作为外部软件一样。

是吗? Docker bundles 有什么是 docker-compose 所没有的?

主要区别在于 docker 捆绑包面向使用此新的服务器端编排功能,它使用 docker 服务内部流程。

docker compose 具有客户端的所有逻辑,因为它是在服务器(守护进程)上执行不同请求的客户端(compose)。

对于 docker 包,所有流都由引擎管理。

A Dockerfile can be built into an image, and containers can be created from that image.

Similarly, a docker-compose.yml can be built into a distributed application bundle(DAB), and stacks can be created from that bundle.

In that sense, the bundle is a multi-services distributable image format.

来源:https://docs.docker.com/v18.03/compose/bundles/

与 docker 相比,DAB 现在有一些功能不可用 - 像链接、批量安装这样的组合。映射到 compose 文件中映射的容器端口的主机端口没有任何关联,因为 Swarm 随机分配一个端口给服务。您可以通过

验证

docker service inspect nginx

当然你可以随时更新服务的端口,例如

docker service update --publish-add 8080:80 nginx