Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy new image in Docker Compose stack without downtime

We have a multi-container application, which uses a microservices architecture, running in Docker Compose.

When I make code changes to the web app, for example, I need to rebuild the image with new code, then run it again in my compose stack, without any downtime.

Here is the current sequence of events that we are using:

  1. Make changes to app code
  2. Rebuild image
  3. Push image(to docker hub)
  4. docker-compose down
  5. docker-compose up

After running docker-compose down, all apps go down. Then docker-compose up brings the whole stack back up.

Is there a way to redeploy individual images in Docker Compose without any downtime, and without bringing down the entire application stack?

like image 389
grizzthedj Avatar asked Jul 12 '17 17:07

grizzthedj


1 Answers

You can avoid to put down everything at the same time (docker-compose down), just with something like this:

docker-compose pull --parallel
docker-compose up --force-recreate <specific-service-name1>

This will pull & stop & recreate (run) your <specific-service-name1> containers, and won't touch any other container.
Later you can deploy the rest:

docker-compose up --force-recreate <specific-service-name2>
docker-compose up --force-recreate <specific-service-name3>
like image 164
Robert Avatar answered Sep 30 '22 16:09

Robert