skip to Main Content

I’m trying to setup zero downtime deploy with docker stack. I succeeded running everything on the server, but when i try to update existing stack with a new tag, data in container doesn’t changes. No errors occur and docker stack ps outputs information that new images are used. Tryed to remove the stack, container, image and clear cache by docker system prune, but it doesn’t works. I can see a new data only when creating a new stack with unique name or deleting /var/lib/docker folder. And also, if i try run an image by docker run , there will be actual data.
In general, everything looks as if there is some kind of cache for docker stack, but i don’t know where is it…

docker-compose.deploy.yml

version: '3.7'
...
php-fpm:
    image: registry.com/web/idm/php-fpm:${IMAGES_TAG}
    depends_on:
      - database
      - redis
    deploy:
      update_config:
        order: start-first
        failure_action: rollback
        delay: 10s
      rollback_config:
        parallelism: 0
        order: stop-first
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s
    volumes:
      - php_files:/var/www
    networks:
      - acs_back

Deploy script on runner

env $( cat .env | grep ^[A-Z] | xargs) IMAGES_TAG=${CI_PIPELINE_ID} docker-compose build --pull
IMAGES_TAG=${CI_PIPELINE_ID} docker-compose push

Deploy script on server

docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY} && 
env $(cat $DEPLOY_PATH/env.file | grep ^[A-Z] | xargs) IMAGES_TAG=${CI_PIPELINE_ID} docker-compose -f $ACTUAL_PATH/docker-compose.deploy.yml pull &&  # Without it sometimes throw errors "unable find image..."
env $(cat $DEPLOY_PATH/env.file | grep ^[A-Z] | xargs) IMAGES_TAG=${CI_PIPELINE_ID} docker stack deploy -c $ACTUAL_PATH/docker-compose.deploy.yml access-control --with-registry-auth

Thanks for your help!

2

Answers


  1. Chosen as BEST ANSWER

    I found out what the problem was. I created a mount volume between php-fpm and nginx - php_files. Apparently, because the services are updated one by one, the mounted directory has never been updated. By removing the shared directory and uploading files to nginx separately, the problem no longer arises.


  2. You will have to use –no-cache option or –build option as available for up command:

    docker-compose up --build

    that will make sure the image is build from scratch and cache is not used.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search