Revanth
Revanth

Reputation: 299

docker stack deploy does not update config

Trying to set up a zero-downtime deployment using docker stack deploy, docker swarm one node localhost environment.

After building image demo:latest, the first deployment using the command docker stack deploy --compose-file docker-compose.yml demo able to see 4 replicas running and can access nginx default home page on port 8080 on my local machine. Now updating index.html, building image with the same name and tag running docker stack deplopy command causing below error and changes are not reflected.

Deleting the deployment and recreating will work, but I am trying to see how can updates rolled in without downtime. Please help here.

Error

Updating service demo_demo (id: wh5jcgirsdw27k0v1u5wla0x8)
image demo:latest could not be accessed on a registry to record
its digest. Each node will access demo:latest independently,
possibly leading to different nodes running different
versions of the image.

Dockerfile

FROM nginx:1.19-alpine
ADD index.html /usr/share/nginx/html/

docker-compose.yml

version: "3.7"
services:
  demo:
    image: demo:latest
    ports:
      - "8080:80"
    deploy:
      replicas: 4
      update_config:
        parallelism: 2
        order: start-first
        failure_action: rollback
        delay: 10s
      rollback_config:
        parallelism: 0
        order: stop-first

Upvotes: 1

Views: 2571

Answers (1)

CantankerousBullMoose
CantankerousBullMoose

Reputation: 512

TLDR: push your image to a registry after you build it

Docker swarm doesn't really work without a public or private docker registry. Basically all the nodes need to get their images from the same place, and the registry is the mechanism by which that information is shared. There are other ways to get images loaded on each node in the swarm, but it involves executing the same commands on every node one at a time to load in the image, which isn't great.

Alternatively you could use docker configs for your configuration data and not rebuild the image every time. That would work passably well without a registry, and you can swap out the config data with little-no downtime:

Rotate Configs

Upvotes: 1

Related Questions