> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fly.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy with a Dockerfile

<img src="https://mintcdn.com/fly-io/v-XOGeVK6s4rQ-4y/images/docker.png?fit=max&auto=format&n=v-XOGeVK6s4rQ-4y&q=85&s=b170bfccc698631f3ae97bf8adc1a8e7" alt="Illustration by Annie Ruygt of a whale carrying containers with fish looking on" width="1200" height="635" data-path="images/docker.png" />

Fly Launch can deploy your app from a [Dockerfile](https://docs.docker.com/reference/dockerfile/).

The `fly launch` command detects your Dockerfile, builds it, and then deploys your app. Need some extra config? No sweat, we've got you covered.

## Create and configure your app

Run `fly launch` from your project's source directory.

<Note>
  If you want to configure more than the basic settings, things like secrets or environment variables for example, run
  `fly launch --no-deploy` so that you can [edit the `fly.toml` file](#more-config) before the first deployment.
</Note>

<CodeGroup>
  ```bash cmd theme={null}
  fly launch
  ```

  ```output output theme={null}
  Scanning source code
  Detected a Dockerfile app
  Creating app in /Users/name/test/my-app-name
  We're about to launch your app on Fly.io. Here's what you're getting:

  Organization: MyOrg (fly launch defaults to the personal org)
  Name: my-app-name (derived from your directory name)
  Region: Secaucus, NJ (US) (this is the fastest region for you)
  App Machines: shared-cpu-1x, 1GB RAM (most apps need about 1GB of RAM)
  Postgres: <none> (not requested)
  Redis: <none> (not requested)

  ? Do you want to tweak these settings before proceeding? Yes

  ```
</CodeGroup>

Type `n` if you're happy with the defaults listed, otherwise type `y` to open the Fly Launch web page and edit your settings, including:

* Name: Keep the default app name or enter your own.

* Region: Keep the fastest [region](/reference/regions) (the value of `primary_region` in the `fly.toml` file) as chosen by Fly Launch, or select a different region to deploy to.

* Services: The port for services (the value of `internal_port` in the `fly.toml` file) depends on the `EXPOSE` instruction in your Dockerfile. The default port when the `fly launch` command doesn't find ports set in a Dockerfile is `8080`.

* You can also set a default Machine size and memory, and add and configure Postgres or Redis.

After you click **Confirm Settings**, Fly Launch creates your app, generates a `fly.toml` file for your project with the settings, and then deploys the app.

### Add environment variables and secrets

Most Dockerfiles expect some configuration settings through `ENV`. Add your custom `ENV` settings to the `[env]` section of the generated `fly.toml` file. For example:

```toml theme={null}
[env]
  MY_SPECIAL_ENV = "some_value"
  MAX_PLAYER_COUNT = "15"
```

Add the values your Dockerfile requires.

Sometimes you have secrets that shouldn't be checked in to `git` or shared publicly. You can set secrets using the [`fly secrets`](/apps/secrets#set-secrets) command. For example:

<CodeGroup>
  `bash cmd flyctl secrets set MY_SECRET=romance ` `output output Secrets are staged for the first deployment `
</CodeGroup>

You can list the secrets you've already set using `fly secrets list`. For example:

```bash theme={null}
fly secrets list
```

```
NAME      DIGEST                           DATE
MY_SECRET b9e37b7b239ee4aefc75352fe3fa6dc6 1m20s ago
```

The values aren't displayed, since they're secret!

### Deploy your app

If you didn't deploy the new app, or you've made changes and want to redeploy, then you can do that now.

<CodeGroup>
  ```bash cmd theme={null}
  fly deploy
  ```

  ```output output theme={null}
  ==> Verifying app config
  Validating /Users/name/test/my-app-name/fly.toml
  Platform: machines
  ✓ Configuration is valid
  --> Verified app config
  ==> Building image
  Remote builder fly-builder-long-glitter-7257 ready
  ==> Building image with Docker

  ...

  --> Pushing image done
  image: registry.fly.io/my-app-name:deployment-01HGEQ1Z1DPMJ4NMPNHTA09T6T
  image size: 141 MB

  Watch your deployment at https://fly.io/apps/my-app-name/monitoring

  ---

  Updating existing machines in 'my-app-name' with rolling strategy

  ---

  ✔ [1/2] Machine 918543b477de83 [app] update succeeded
  ✔ [2/2] Machine e28697ce6d3986 [app] update succeeded

  ---

  Visit your newly deployed app at https://my-app-name.fly.dev/

  ```
</CodeGroup>

By default, `fly deploy` builds the image using a remote builder. If you have Docker running locally and want to build locally, then run `fly deploy --local-only`. After the image is built, the app gets deployed.

### Open your app

Run `fly apps open`, or just go to the URL specified in the output, to open your deployed app in a browser.

## Stateful apps

Lots of apps have some state that they want to keep. Learn more about the options for [databases and storage](/database-storage-guides) on Fly.io.

## Grow and scale

Check out some of the ways you can increase availability, capacity, and performance with Fly.io:

* Follow the blueprint for [extra Machines for more resilient apps](/blueprints/resilient-apps-multiple-machines)
* Read up on [App availability and resiliency](/apps/app-availability)
* [Autoscale Machines based on load or custom metrics](/reference/autoscaling)
* [Scale Machine CPU and RAM](/launch/scale-machine)
* [Scale Machine count](/launch/scale-count)

If you have questions, need help, or want to talk about what you're building, visit our [community forum](https://community.fly.io).

```
```
