docker-compose shared volumes

wrldzPRO

a year ago

If you specify that two services will share the same storage volume in a docker-compose file and then deploy the template created from that docker-compose file, I don't believe the services are sharing the same volume. If I am right about this, is there any way for separate services to share a storage volume using Railway?

Solved

11 Replies

a year ago

Railway does not yet support shared volumes, or even two volumes on one service.


wrldzPRO

a year ago

Ahh I see. The problem I am trying to solve is being able to write files to a service's volume and the only way to do that seems to be to implement that capability within the OSS that I am using and then create my own docker image.


a year ago

if you only need to place the files in the volume once you can do that then attach the volume back to its service.


wrldzPRO

a year ago

Yes, I have done some testing using that logic, but I really need to be able to dynamically write to the volume while the service is deployed.


a year ago

Gotcha, unfortunately, that isn't possible right now, you where correct when you said the service itself would need to implement that functionality.


sanouhi99PRO

3 months ago

Hello,

I need to know if there is a way to use the same volume with two services on Railway. I have a Flask API and a worker script, and both need to read and write to a file stored in that volume.

Is this possible, and if so, how can I set it up?

Thank you!


3 months ago

Hello,

It is not possible.

You would need to use external storage like MinIO, or run the API and Worker within the same service so they they both have access to the mounted volume.


sanouhi99PRO

3 months ago

Thank you for your response. I have already set up the API and worker within the same service so they can access the mounted volume.

Now, my challenge is ensuring that:

  • The Flask API runs continuously (24/7).

  • The worker script runs only once per month.

What would be the best approach to achieve this setup within Railway?

I appreciate your guidance!


3 months ago

  1. This is how it's done by default, your deployment runs 24/7 unless you enable serverless, but serverless is off by default.

  2. Are you sure you want it to run once per month, sorry but that sounds very incorrect.


sanouhi99PRO

3 months ago

Yes, I want the Flask API to run 24/7 (to handel data from my site), and the worker script to execute only once per month (to process that data).

Currently, since both are part of the same service, the worker would also run continuously, which is not what I want. Ideally, I need a way to schedule the worker script to run once per month without keeping an unnecessary process running the rest of the time.


3 months ago

Then you would need to configure your worker to only start once per month, likely with an in-code cron schedule.

Unfortunately we cannot help with the code implementation of that.


Status changed to Solved brody 2 months ago