grizzthedj
grizzthedj

Reputation: 7505

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?

Upvotes: 7

Views: 3302

Answers (1)

Robert
Robert

Reputation: 36773

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>

Upvotes: 6

Related Questions