Zero down-time deployments using docker-compose?

I’ve pulled together a cd solution for my own little personal projects using docker-compose, but no matter what I try I have ~10 seconds of down-time every time I redeploy.

My CI service uploads new docker images under certain tags, and then hits a webhook. The webhook triggers the following script:

docker-compose pull
docker-compose up -d

Here is my docker-compose:

version: '3'

services:
  backend:
    restart: always
    image: <image name>/backend:latest
    deploy:
      replicas: 2
    networks:
      - back
  static:
    restart: always
    image: <image name>/static:latest
    deploy:
      replicas: 2
    depends_on:
      - backend
    ports:
      - "7180:80"
    networks:
      - front
      - back

networks:
  front:
  back:

The replicas seems to be ignored, since I’m not in swarm mode. I’m not 100% sure what swarm mode is. I’m starting to venture into several areas I’m not very comfortable, and thought I’d seek some advice. What should I do to have zero down-time deployments?

Source: StackOverflow