10

I have

Error response from daemon: rpc error: code = InvalidArgument desc = only updates to Labels are allowed

when redeploying stack

docker stack deploy -c docker-compose.yml --with-registry-auth monitoring
Ryabchenko Alexander
  • 10,057
  • 7
  • 56
  • 88

4 Answers4

22

Unfortunately, as Ryabchenko Alexander said, docker configs cannot be updated, see moby issue.

In one approach you can remove the services that use the new configs, with the command docker service rm service_name.

Then remove the config with docker config rm config_name and redeploy the stack to update the config and recreate the removed services.

Update: see this comment if it is necessary to have no downtime.

Mohsenasm
  • 2,916
  • 1
  • 18
  • 22
6

The suggested removing stack/service approach brings DOWNTIME.

Fortunately, there is a tricky workaround for this issue without downtime. Simply set a name for your config/secret and change that name with help of environment variables every time you run the docker stack deploy command:

version: '3.7'
services:
  nginx:
    image: nginx:alpine
    configs:
      - source: nginxconf
        target: /etc/nginx/foobar.conf
configs:
  nginxconf:
    name: nginx.conf-${CONFIG_VERSION:-0}
    file: ./nginx.conf

For the next deployments, change that variable first and then, run docker stack deploy:

CONFIG_VERSION=1 docker stack deploy -c docker-compose.yml mystack

You can read more here.

Erfun
  • 1,079
  • 2
  • 11
  • 26
  • Note that you get the same error, if you use the same CONFIG_VERSION twice. I use a wrapper deploy -script that sets it either to CI build number or export CONFIG_VERSION=$(date +%Y%m%d%H%m%s) – PHZ.fi-Pharazon May 28 '22 at 11:22
2

You can also publish a new conf, versioning it in the name.

I use yml files to deploy and update stacks. If I change a conf file I rename the reference in the yml file (i.e. from conf-v1 to conf-v2) and deploy again: docker creates a new conf and refers to it.

Pros:

  • no labels error
  • safest on docker auto rollback if deploy fails (if conf-v2 has breaking changes rollback makes the stack refer to conf-v1 again, I suppose)

Cons:

  • lots of conf to be removed
ggg
  • 86
  • 4
1

https://github.com/moby/moby/issues/35048

The only way to update config is to remove stack and redeploy it

docker stack rm <my_stack_name>
docker stack deploy -c docker-compose.yml --with-registry-auth <my_stack_name>
Ryabchenko Alexander
  • 10,057
  • 7
  • 56
  • 88