multi container apps?

Hello,

I’m new to fly.io, have just deployed my first app and have a stupid newbie question:

Is it possible to run multiple containers per app? (I assume yes, that’s needed for scaling, right?). But is it also somehow possible to run multiple containers with different container images? (like docker.io/me/mywebapp, docker.io/me/mysidecar, etc)?

Or would I have to refactor these images all into one image (i.e. using supervisord)?

Thanks!

Hey,

Ah, well Fly does not support the docker compose style (it does not actually use Docker at all) so you do need one image per app. A Dockerfile can be used to tell Fly how that image is made.

Within that image you can run multiple processes. For example you could run nginx as a process, and php-fpm as a process, and keep both running by a process manager. Yep, like supervisord (as you mention). So one app, and one vm.

Or you can run multiple processes in app but have Fly handle that. Behind the scenes, I think each is in its own vm, but they are within the same app. So one app, multiple vms. This kind of thing in the fly.toml (not tried myself, taken from Laravel):

[processes]
  app = ""
  worker = "php artisan queue:work"
  cron = "cron -f"

Or you can multiple apps. One app for e.g your database, one for redis, one for the webapp etc. Costs more, but that approach means they can be scaled independently. And they can all talk to each other over a private encrypted network.

Fly have written a great guide which should help: Running Multiple Processes Inside A Fly.io App · Fly Docs

4 Likes

thanks a lot! That’s good to know. The processes definition in fly.toml might actually save me from having to deal with supervisord. (But I still need to modify my image).

Unfortunately using multiple apps isn’t an option for my specific case as I need to access a volume from all processes. (And as volumes are part of apps I assume they can not be shared between apps?)

Again, thanks for your help!

1 Like

Note that if you use processes, only one instance of one process will be able to mount the volume, since the processes run in separate VMs. You’ll need to use something like supervisord if you want your processes to access the same volume.

2 Likes

oh, I see. Thanks for pointing that out.