(Backup/Migration Help) Display/export/etc. existing settings for containers created with docker-compose after .yml file corrupted/deleted

Hi folks. I have a stack that I created with docker-compose. Unfortunately, the docker-compose.yml file is now empty, I’m not sure if it got corrupted or deleted, but it’s gone.

I’m hoping you folks know a way to… display? export? the running configuration that was in that file, so I can see how those containers were created. The ultimate goal is to migrate these containers to another host(s), along with their config data. Once I can confirm that they are running as expected on the new host, I can shut down the old host, wipe it, and install a fresh OS/config/etc.

This is for a “home media” server, I currently have running on an Intel NUC connected to a Synology 1513+ NAS. This is obviously not mission-critical or a business use case, so while I’d prefer not to, I’m sure I can trial and error my way through this. I say that because your folks’ time is valuable, and I don’t want someone knocking themselves out trying to help me.

I have Portainer running, if that helps. I did not create the stack using that (which I somewhat regret now, but I this is my first expose to containers, and I love what I’m learning!). I can view the config in Portainer, but the way it is displayed is kinda confusing, and I’m concerned I won’t be able to use that to recreate these containers using this method.

Host OS is currently Ubuntu 20.xx. I’m not a “Linux guy” (I know I know! Please stop throwing tomatoes!) and would personally prefer running these in Windows, but have been using this as a learning mechanism for both Docker and Linux, so if that’s the consensus, I’m perfectly fine with sticking with Linux.

I’m all ears for any advice, tips, tricks, whatever. I’ve already learned so much during this process, and have already begun laying out a detailed approach I intend on taking to avoid this in the future. This includes regular backups, high(ish) availability, and more. I’m also trying to determine if it’s possible to run these “home media” applications using something like Docker Swarm. Lots of ideas, and looking for more, if y’all are willing.

Thank you all so much for your help. I hope you are having a great day.

Did you ever find a way? same exact problem here :frowning:

You could check if the red5d/docker-autocompose image does what you want::

 docker run --rm -v /var/run/docker.sock:/var/run/docker.sock red5d/docker-autocompose <container-name-or-id> <additional-names-or-ids>...

I know that it creates a compose file from a container, not sure though if it’s able to re-create a multi-service compose file.

I tried it now, real quick, for one of my running containers, and it seems perfect.
I’ll just foreach through all my containers, and I should have a working compose.yml again. Then I’ll just rewrite it slightly to use my .env-file, and Robert should indeed be your father’s brother!

Thanks so much!


Almost, as the resulting compose file will have ALL elements a container has, and not just those you configured yourself for the container. So you’ll have to strip the compose file down to keep it maintainable.

But indeed, it’s a good starting point.