wowu / docker-rollout

🚀 Zero Downtime Deployment for Docker Compose
https://github.com/Wowu/docker-rollout
MIT License
2.37k stars 66 forks source link

Sometimes need to manually reload NGINX for this to work #30

Closed cjacky475 closed 4 months ago

cjacky475 commented 4 months ago

My docker-compose.yml is:

services:
  backend:
    image: backend-api
    restart: unless-stopped
    networks:
    - proxyNetwork
  frontend:
    image: frontend
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    depends_on:
      - backend
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
    networks:
      - proxyNetwork
  <...>
  1. Running docker rollout -f docker-compose.yml backend results in it actually working every second time, not sure why. First time I call this the frontend cannot call the backend, it says 404, second time I use docker rollout ... then it starts working. And it only works every second time, not sure why. The time it's not working I have to call docker compose exec frontend /usr/sbin/nginx -s reload for it to work.
  2. Also, if I wanted to reload frontend image as well, I have to extract nginx into different service, right? Since I cannot set port for the image to be reloaded.

Cheers for the help.

wowu commented 4 months ago

I suggest running a reverse proxy container that supports service discovery like nginx-proxy or traefik as described in readme (https://github.com/Wowu/docker-rollout#%EF%B8%8F-caveats). Your setup will not work as docker-rollout does not have any hook or callback support yet for the reload command. You can try to modify the script to add the reload command, or use the recommended setup (see https://github.com/Wowu/docker-rollout/tree/main/examples)

cjacky475 commented 4 months ago

Hi, @Wowu, thanks for the answer. Actually I have plain NGINX as reverse proxy, but not the nginx-proxy image itself with auto detection. As you mentioned to modify the script, would this still be fine for production system? I believe putting it below

 # shellcheck disable=SC2086 # DOCKER_ARGS and OLD_CONTAINER_IDS must be unquoted to allow multiple arguments
  docker $DOCKER_ARGS stop $OLD_CONTAINER_IDS
  # shellcheck disable=SC2086 # DOCKER_ARGS and OLD_CONTAINER_IDS must be unquoted to allow multiple arguments
  docker $DOCKER_ARGS rm $OLD_CONTAINER_IDS

is appropriate, right? Any consequences?

Thanks.

wowu commented 4 months ago

Yes, it should be alright. However, it will be more difficult to update docker rollout when a new version is available.

cjacky475 commented 4 months ago

Thanks, I hope you guys add hook/callback support for reload command :) Cheers.