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

查看:370
本文介绍了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/


启动服务的现有容器。

Starts existing containers for a service.

docker-组成

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日志-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天全站免登陆