docker和docker-compose有什么区别 [英] What is the difference between docker and docker-compose

查看:163
本文介绍了docker和docker-compose有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

docker docker-compose 似乎与同一个dockerFile交互,两者之间有什么区别

docker and docker-compose seem to be interacting with the same dockerFile, what is the difference between the two tools?

推荐答案

docker cli在管理单个容器时使用一个docker引擎。这是访问docker daemon api的客户端命令行。

The docker cli is used when managing individual containers on a docker engine. It is the client command line to access the docker daemon api.

docker-compose cli可用于管理多容器应用程序。它还会将您在 docker run cli运行时输入的许多选项移到 docker-compose.yml 文件中,更容易重用。它在 docker 使用的同一docker api上充当前端脚本,因此您可以执行 docker-compose 使用 docker 命令和大量的Shell脚本。有关更多详细信息,请参见此有关docker-compose的文档

The docker-compose cli can be used to manage a multi-container application. It also moves many of the options you would enter on the docker run cli into the docker-compose.yml file for easier reuse. It works as a front end "script" on top of the same docker api used by docker, so you can do everything docker-compose does with docker commands and a lot of shell scripting. See this documentation on docker-compose for more details.

群模式更新

由于发布了此答案,码头工人添加了第二个使用docker-compose.yml文件的功能。从版本3 yml格式和docker 1.13开始,您可以使用yml与docker-compose并在docker的swarm模式下定义堆栈。为此,您需要使用 docker stack deploy -c docker-compose.yml $ stack_name 而不是 docker-compose up ,然后使用 docker 命令而不是 docker-compose 命令管理堆栈。映射是两种用途之间的一对一映射:

Since this answer was posted, docker has added a second use of docker-compose.yml files. Starting with the version 3 yml format and docker 1.13, you can use the yml with docker-compose and also to define a stack in docker's swarm mode. To do the latter you need to use docker stack deploy -c docker-compose.yml $stack_name instead of docker-compose up and then manage the stack with docker commands instead of docker-compose commands. The mapping is a one for one between the two uses:


  • 撰写项目->群群:一组用于特定目的的服务

  • 组合服务->群集服务:一个图像及其配置,可能会放大。

  • 组合容器->群集任务:一个容器中的一个服务

有关群体模式的更多详细信息,请参见码头工人的蜂群模式文档

For more details on swarm mode, see docker's swarm mode documentation.

这篇关于docker和docker-compose有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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