swarmpit
swarmpit copied to clipboard
Reversing Docker Compose file from running stack
Hello sorry to ask here, but it will be very helpful if I get answer from here. I saw if I tried to edit a stack in swarmpit then it shows the exact docker-compose file's content that I had use while deploying the stack, now I only want to know how swarmpit is doing this, I tried to check all docker commands but haven't find anywhere.
I am doing little development in bash and python, and I need it there so I could see the docoker compose file content for my existing running stack. If you help me that how I can do then it will be great for me.
Thanks
there is no easy way to do it, we're basically querying the current state of swarm and using this data to rebuild some valid stackfile from it. we also use same approach to convert single service into stack.
best way to start looking into how we do it is here https://github.com/swarmpit/swarmpit/blob/38ffbe08e717d8620bf433c99f2e85a9e5984c32/src/clj/swarmpit/docker/engine/mapper/compose.clj#L138
if you have swarmpit deployed in your swarm, you can use its API to let it generate stackfile for you
api/stacks/{name}/compose
HI thanks for your response.
Ok I had tried this
https://myswarmpit.local/api/stacks/<stack_name>/compose
but got this "Authentication failed", would you please help me how I can use the api
@umardraz you need to generate API token first in settings section of Swarmpit.
Yes I did it and it worked.
Now the question is, is there a way that I can launch swarmpit as API only and and define my own api token in swarmpit docker-compose file and deploy?
@umardraz You can't. To do that new build without FE part will be required.
Hmm, it will be really a great feature if we can launch API only as well