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
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.
service config rm config_name
you saved my day, thank you for your answer
Dec 27, 2022 at 9:44
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.
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:
conf-v2
has breaking changes rollback makes the stack refer to conf-v1
again, I suppose)Cons:
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>