如何使用docker-compose重新启动单个容器 [英] How to restart a single container with docker-compose

查看:6905
本文介绍了如何使用docker-compose重新启动单个容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 docker-compose.yml 文件,其中包含4个容器:redis,postgres,api,worker



<在工人的发展过程中,我经常需要重新启动它才能应用变更。有没有什么好的方法来重新启动一个容器(例如 worker )而不重新启动其他容器?

解决方案这很简单:使用命令:

  docker-compose restart worker 

您可以设置等待停止的时间,然后再杀死容器(以秒为单位)

  docker-compose restart -t 30 worker 

全部!


I have a docker-compose.yml file that contains 4 containers: redis, postgres, api, worker

During the development of worker, I often need to restart it in order to apply changes. Is there any good way to restart a container (e.g. worker) without restarting the other containers?

解决方案

It is very simple: Use the command:

docker-compose restart worker

You can set the time to wait for stop before killing the container (in seconds)

docker-compose restart -t 30 worker

Thats all !

这篇关于如何使用docker-compose重新启动单个容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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