I'm using docker swarm deploy -c docker-compose.yml somestack
to deploy to a docker swarm. However, I can later scale it with docker service scale somestack_someservice=5
(or whatever). So now docker-compose.yml no longer reflects the system. My question is, is there any way to save off the current configuration of the stack, and then later reapply it, similar to how I originally created it (with docker-compose.yml)?
There is no direct way to generate docker-compose.yml
file, although you can use
docker service inspect --pretty <service-name>
command to obtain all configuration in text/json format.
There are some chances we can try to create docker-compose.yml
from it.
Also, think about lack of this feature as advantage. If you want to make some adjustments, make them in docker-comose.yml
first and then call docker stack deploy
to apply it.