How to restart a single container with Docker Compose

Jan 22, 2022 · 1 min read · Post a comment

Restarting Docker Compose stack (docker-compose restart) it’s pretty easy and convenient, and if you somehow screw up something, docker-compose down/up will take care of it. But, now the question is, how can we restart a single Docker Compose service running one or multiple containers, without taking down the whole stack.


  • Docker
  • Docker Compose

Restart a single container without previously applied any changes

docker-compose restart db_service

If you want to add a time to wait before restarting, run:

docker-compose restart -t 10 db_service

Restart a single container with applied changes

docker-compose up --detach --build db_service

or, if you want to apply changes to any service within the docker-compose stack:

docker-compose up --detach --build


As a next step, I would consider deploying Docker Compose with zero downtime. It’s possible though without Docker Swarm or Kubernetes, kind of DIY blue/green deployment. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.