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

4 Answers 4

21

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.

2
  • 4
    This approach is better than removing the whole stack!
    – Peyman.H
    Apr 14, 2020 at 11:35
  • 1
    by service config rm config_name you saved my day, thank you for your answer Dec 27, 2022 at 9:44
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.

1
  • 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) May 28, 2022 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
1
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>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.