Where are the Stack compose files saved?
hey guys,
just want to ask where I can find the docker-compose.yml's if I deploy my stacks with the webGui? I tryed saving the data volume of portainer and transfer it to a new host and then deploy the same portainer stack file and all my "old" stacks aren't there anymore.
Is there a possibility to extract them to github everytime I change them or maybe just extract them to the data volume?
Thank you all in advance.
Portainer 1.23.0 is used.
Are you managing the same endpoint with the new Portainer instance? If not, then your old stacks will not be listed inside of Portainer as you haven't migrated them also. If you can see your stacks, but they are showing as limited this is because Portainer couldn't find the corresponding stack file and could possibly be due to how you have mounted your volume.
I can't give you instructions on how to migrate as we don't have any official instructions for this.
To answer your question: Inside the /data directory there is a directory called compose which is where the stack files are stored. Inside /compose, there will be directories labelled after the corresponding stackID in the Portainer database. You will have for example /data/compose/1/docker-compose.yml, /data/compose/2/docker-compose.yml ...
Hope this helps
perfect! That was what I was looking for :)
As this is one of the first search results that comes up on google when looking for the location of stack compose files, here is the location for a "standard" install on linux:
/var/lib/docker/volumes/portainer_data/_data/compose/
What would I have to restart from the outside in order to reload a compose file?
Should I just issue a docker-compose up -d in the respective directory?
As this is one of the first search results that comes up on google when looking for the location of stack compose files, here is the location for a "standard" install on linux:
/var/lib/docker/volumes/portainer_data/_data/compose/
thank you 👯
im have error message like this and im create folder 150 in compose directory

You will have for example
/data/compose/1/docker-compose.yml,/data/compose/2/docker-compose.yml
This is true for the main portainer app. For agents, it's slightly different. When installing app 1337 through the agent (on machine2, stressing this), communicating with the main portainer on machine1 you'll have:
- Mounted volumes, secrets,... relative to
/data/compose/1337onmachine2 - BUT, the compose stack file is stored on
machine1, relative to the location of portainer's own stack compose file. This means if you have the docker-compose for portainer installed at/opt/portainer/docker-compose.yml, the stack file for1337will be at/opt/portainer/portainer_data/compose/1337/docker-compose.yml
Sorry for necrobumping this, but I haven't found this info mentioned elsewhere, and as stated above this page comes often when searching for the location of stack files.
Edit: Apparently this is not exactly correct: My docker-compose file for portainer contains a volume
volumes:
- ./portainer_data:/data
responsible for this behavior. So while the above is not universal, there's definitely a different treatment for files from the agent compared to files from the main app.
hi, I'm using a bind volume for Portainer data
volumes:
- /Users/MyUSerName/MySubFolder/volumes/portainer/data/:/data
- /var/run/docker.sock:/var/run/docker.sock #this one adds local environment
when deploying a stack the /data/compose/ folder is scanned as a reference folder:
/Users/MyUserName/MySubFolder/portainer/data/
As I'm using docker desktop at the moment to deploy firefly_iii, I need to specify in my stack/compose file:
env_file: ../firefly_iii/.env
which is actually in /Users/MyUserName/MySubFolder/portainer/data/compose/firefly_iii/.env
I've tried to use and different folder, and specify it in the stack
env_file: /Users/MyUserName/MySubFolder/firefly_iii/.env
But it never worked!!
I hope this helps, it took me a while to figure it out ✌️
As a hint for everyone who is teaching - For me it looked like this: I've got a local proxmox Host with an LXC container running portioner. That portioner was connected to a remote docker installation via the standard portioner agent. The portioner installation got a stack managed on the remote docker instance. Not that connection was for whatever reasons broken. I could not get it back working and had to switch to the edge agent. But doing so of course left me with no stacks even the local and remote installations haven't changed.
I had to look into my folder
/home/portainer/portainer/data/compose/
where are several numbered folders resist containing all the docker-compose.yml files