Answer the question
In order to leave comments, you need to log in
How to deploy a docker container without downtime?
What we have:
2 docker containers: app (node.js) and nginx (reverse-proxy)
Requirement:
Have a minimal service downtime.
Some queries may take a long time to complete. It is important to return the response to the request that came before the deployment.
The essence of the problem:
When updating the project (docker-compose build && docker-compose up -d), we have a simple 5-10sec. (start time of node.js in app container).
As I imagine the solution:
1. Using the Green / Blue pattern. Couldn't find a simple solution (without crutches)
2. Docker Swarm Stack
Tell me the simplest possible approach to deployment with zero downtime (in the absence of DevOps'a).
docker-compose.yml
version: '3.3'
services:
app:
build:
context: .
restart: unless-stopped
env_file: .env
nginx:
build: ./docker/nginx
restart: unless-stopped
depends_on:
- app
ports:
- ${APP_PORT}:80
volumes:
- ./static:/var/www:cached
Answer the question
In order to leave comments, you need to log in
How I imagine the solution:
Initialize Docker Swarm with one node.
Create a service with an application - app.
And update the service with the necessary parameters to eliminate downtime.
Simple example:
docker service create --name nginx --replicas 1 --publish 80:80 nginx:1.18
docker service update nginx --update-order start-first --image nginx:1.19
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question