如何在 docker-compose.yml 中重建 docker 容器? [英] How to rebuild docker container in docker-compose.yml?

查看:58
本文介绍了如何在 docker-compose.yml 中重建 docker 容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

docker-compose.yml 中定义了服务范围.这些服务已经启动.我只需要重建其中一个并在没有其他服务的情况下启动它.我运行以下命令:

docker-compose up -d # 运行所有服务docker-compose stop nginx # 只停止一个.但它仍在运行!!!docker-compose build --no-cache nginxdocker-compose up -d --no-deps # 将 nginx 链接到其他服务

最后我得到了旧的 nginx 容器.顺便说一句,docker-compose 不会杀死所有正在运行的容器!

解决方案

docker-compose up

$ docker-compose up -d --no-deps --build 

<块引用>

--no-deps - 不要启动链接服务.

<块引用>

--build - 在启动容器之前构建镜像.

There are scope of services which defined in docker-compose.yml. These service have been started. I need to rebuild only one of these and start it without up other services. I run the following commands:

docker-compose up -d # run all services
docker-compose stop nginx # stop only one. but it still running !!!
docker-compose build --no-cache nginx 
docker-compose up -d --no-deps # link nginx to other services

At the end i got old nginx container. By the way docker-compose doesn't kill all running containers !

解决方案

docker-compose up

$ docker-compose up -d --no-deps --build <service_name>

--no-deps - Don't start linked services.

--build - Build images before starting containers.

这篇关于如何在 docker-compose.yml 中重建 docker 容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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