Launch an App on Fly
Fly.io allows you to deploy any kind of app as long as it is packaged in a Docker image. That also means you can just deploy a Docker image and as it happens we have one ready to go in
Each Fly.io application needs a
fly.toml file to tell the system how we'd like to deploy it. That file can be automatically generated with the
flyctl launch command, which will ask a few questions to set everything up. Let's run through it now:
fly launch --image flyio/hellofly:latest
? App Name (leave blank to use an auto-generated name):
Here you can enter the name of the app. Please note that you can only use numbers, lowercase letters and dashes.
? Select organization: Personal (personal)
Organizations: Organizations are a way of sharing applications and resources between Fly.io users. Every Fly.io account has a personal organization, called
personal, which is only visible to your account. Let's select that for this guide.
personalorganization will be selected automatically.
Next, you'll be prompted to select a region to deploy in.
? Select region: ord (Chicago, Illinois (US))
At this point, flyctl creates a shell of an app for you and writes a starter configuration to a
The CLI will ask if you need a Postgres or Redis database. You can reply "No" for this demonstration.
? Would you like to set up a Postgresql database now? No ? Would you like to set up an Upstash Redis database now? No
Lastly, the CLI will ask you if you would like to deploy now—if you're deploying an app that doesn't use
internal_port = 8080, please say no, and take a moment to edit
? Would you like to deploy now? Yes ==> Building image
Whether you deploy straight away or not,
flyctl will download a
fly.toml configuration file to the working directory, for use on the next deployment.
app = "hellofly" [build] image = "flyio/hellofly:latest" [[services]] internal_port = 8080 ...
The Fly CLI will always check to see if this file exists in the current directory, specifically for the
app name value at the start. Many commands use this app name to determine which Fly App to apply to by default.
You can also see how the app will be built (from a pre-built Docker image, in this case), that internal port setting, and further configuration to be applied to the application when it deploys.
If you stopped to customize your
fly.toml, you'll want to deploy your app now. At the command line, just run:
This will get the app name
fly.toml. Then flyctl will start the process of deploying your application to the Fly.io platform. flyctl will return you to the command line when it's done.