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

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

问题描述

每当我执行

docker-compose start 
docker-compose ps

我看到我的容器状态为UP".如果我这样做

I see my containers with the state "UP". If I do

docker-compose up -d

我会看到更详细的内容,但它会有相同的状态.这两个命令有什么区别吗?

I will see more verbose but it will have the same state. Is there any difference between both commands?

推荐答案

docker-compose start
(https://docs.docker.com/compose/reference/start/)

为服务启动现有容器.

docker-compose up
(https://docs.docker.com/compose/reference/up/)

为服务构建、(重新)创建、启动和附加到容器.

Builds, (re)creates, starts, and attaches to containers for a service.

除非它们已经在运行,否则此命令还会启动任何链接的服务.

Unless they are already running, this command also starts any linked services.

docker-compose up 命令聚合每个容器的输出(基本上运行 docker-compose logs -f).当命令退出时,所有容器都停止了.运行 docker-compose up -d 启动容器在后台运行.

The docker-compose up command aggregates the output of each container (essentially running docker-compose logs -f). When the command exits, all containers are stopped. Running docker-compose up -d starts the containers in the background and leaves them running.

如果有一个服务的现有容器,并且该服务的容器创建后配置或图像已更改,docker-compose up 通过停止并重新创建容器(保留安装的卷).为了防止 Compose选择更改,使用 --no-recreate 标志.

If there are existing containers for a service, and the service’s configuration or image was changed after the container’s creation, docker-compose up picks up the changes by stopping and recreating the containers (preserving mounted volumes). To prevent Compose from picking up changes, use the --no-recreate flag.

完整的 CLI 参考:
https://docs.docker.com/compose/reference/

For the complete CLI reference:
https://docs.docker.com/compose/reference/

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

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