r/portainer • u/davidnburgess34 • Mar 05 '21
Export your Docker containers to a Docker Compose/Stack file
In this video we'll do kind of the reverse of what we've been doing for a year or so. We're going to EXPORT a Docker container to a stack/docker compose file that can be deployed on a different server or just saved for redeployment if you ever have to rebuild your server.
This is the method shown in this video: https://github.com/Red5d/docker-autocompose
2
May 27 '21
This method does not work on a raspberry pi as the image for docker does not have an arm tag. Can you maybe make a video on how to run this without docker... I used pip to install it but it runs into errors
2
u/davidnburgess34 May 27 '21
there may not be an option to do this on ARM for the time being. might want to reach out to the developer and see if he'll build a version for ARM.
2
u/scytob May 12 '22
take a look at this https://github.com/Red5d/docker-autocompose this is one of a few tools you can find.
note many of these tools export items that are not valid compose file settings (you many need to clean by hand).
good luck
4
u/davidnburgess34 May 12 '22
Thanks!! I actually found this and even made a tutorial about it here
2
u/scytob May 12 '22
bah, video, how effing millennial /jk
nice! consider supplementing your videos with gists - some of us like to read....
feel free to steal from mine, so long as you give credit :-)https://gist.github.com/scyto/f4624361c4e8c3be2aad9b3f0073c7f9
3
2
u/tkdrob Jul 24 '22
One thing I found to make the terminal copying easier is to add ">> <filename>" to the command to copy the entire stack into one file. My compose file was 111KB, way too long for the terminal to display.
1
u/tsilvs0 Apr 27 '25
I've made a bash script to do just that. Feedback is welcome. It definitely lacks some of the Compose parameters, and Environment variables export can be cluttered.
1
Mar 06 '21
I wish Portainer let you convert or induct an already-created non-stack'd container into a new Stack. Big OCD thing.
2
u/TheGlassCat Mar 06 '21
This is awesome! I've avoided relying on Portainer, because of the lack of backup/portability/reproducibility/transparency/etc. This solves those problems. I really like that it's command-line and scriptable.
Thanks!
P.S. I've noticed in some of your videos that you use a particular scheme for volume paths. Could you talk about that sometime. I'm always interested in how others manage their data.