portainer icon indicating copy to clipboard operation
portainer copied to clipboard

Where are the Stack compose files saved?

Open nicedevil007 opened this issue 6 years ago • 9 comments

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.

nicedevil007 avatar Jan 22 '20 16:01 nicedevil007

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 ...

ghost avatar Jan 23 '20 02:01 ghost

Hope this helps

ghost avatar Jan 23 '20 02:01 ghost

perfect! That was what I was looking for :)

nicedevil007 avatar Jan 23 '20 07:01 nicedevil007

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/

pconwell avatar Dec 05 '20 23:12 pconwell

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 image

denzfarid avatar Dec 07 '22 01:12 denzfarid

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/1337 on machine2
  • 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 for 1337 will 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.

Battleman avatar Feb 08 '23 08:02 Battleman

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 ✌️

punkyard avatar Aug 23 '23 03:08 punkyard

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

Spacey-Rat avatar Mar 06 '25 10:03 Spacey-Rat