Today I Learned

Persistence between Coolify docker deployments

Oct 26, 2025

There's apparently a fairly common mistake when trying to mount a specific file as a volume using docker compose.

If you're trying to mount a file, you must use an absolute path to the file. Also, you have to make sure that the file exists in the first place!

The failure is non-obvious. The "copy" of the non-existent file in your image will actually be a directory of the same name. You might even exec into the image to verify the file is there... and you'll see the name of the file you're expecting to see.

But instead, it will be a directory with a name like this_is_a_file.txt 😁😰

This is VERY confusing, especially if you are 100% certain that the file exists! (It doesn't.)

I found this out the hard way when trying to mount a file using Coolify's Docker Compose build pack.

Thankfully, there's a workaround!

In order to have a "persistent" file that you can refer to between deploys, Coolify allows for persistent storage between builds. You provide a source path and destination (which should match what is in your docker compose file), and then you can indicate if it should be a file or a directory. If it's a file, you can copy/paste the contents directly through the Coolify interface.

It's not very obvious, but I'm glad that there's a solution for this!