Equivalent of heroku run (executing within One-Off Container)

Does fly have something equivalent to heroku’s run command that executes a command within a one-off container (on heroku they call this a one-off dyno. I am aware of flyctl ssh console, but that isn’t the same in that the command is run within an already running instance and commands run may then interfere with the service.

I find fly ssh console to be the best way since what I’m running tends to have side effects relating to the current app, but if you don’t want that, Machines might be worth a try.

You have to create a separate app to store the machines within, but they can run off the same images as your other apps. So for example:

fly apps create --machines

Then staying in the same directory as my running app, I could run:

fly machine run -a <name of my machines app> . "ls -la /"

… which would then use the same Dockerfile, etc, spin up a “machine” and run the ls command before closing down again.

I find this to be a rather slow process though, and hopefully someone with more experience can advise further as I never use this mechanism myself and may have got it wrong! :slight_smile:

1 Like

Just chiming in here to say that I’m also looking for a solution for this.

My use case is that about twice a month I need to go in and run custom scripts that take about an hour each. I don’t want this to run on my normal web apps. A “one-off dyno” is best. Looking for 2 things

  1. On fly, I’d like to specify the memory of the one-off machine like I did on heroku. Equivalent of:
    heroku run rails console --size=performance-l

  2. I’d like to spin up a machine and perform operations live.

irb(main):001:0> Operation.run_some_script
irb(main):002:0> output of script. Depending on output, I run other scripts
irb(main):003:0> Operation.script_a OR Operation.script_b OR paste live snippets from my editor to run