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

# How to deploy via Docker Image

> Learn how to deploy your code to Aptible from a Docker Image

## Overview

Aptible lets you deploy via Docker image. Additionally, [Aptible's Terraform Provider](/docs/reference/terraform) currently only supports this deployment method.

This guide will cover the process for deploying via Docker image to Aptible via the CLI, Terraform, or CI/CD.

## Deploying via the CLI

<Warning>Prerequisites: Install the [Aptible CLI](/docs/reference/aptible-cli/cli-commands/overview)</Warning>

### 01: Create an app

Use the `aptible apps:create` to create an [app](/docs/core-concepts/apps/overview). Note the handle you give to the app. We'll refer to it as `$APP_HANDLE`.

### 02: Deploy a Docker image to your app

Use the `aptible deploy` command to deploy a public Docker image to your app like so:

```js theme={null}
aptible deploy --app "$APP_HANDLE" \
        --docker-image httpd:alpine
```

After you've deployed using [aptible deploy](/docs/reference/aptible-cli/cli-commands/cli-deploy), if you update your image or would like to deploy a different image, use [aptible deploy](/docs/reference/aptible-cli/cli-commands/cli-deploy) again (if your Docker image's name hasn't changed, you don't even need to pass the --docker-image argument again).

<Note>If you are migrating from [deploying via Git](/docs/how-to-guides/app-guides/deploy-from-git), you should also add the --git-detach flag to this command the first time you deploy. See [Migrating from deploying via Git](/docs/how-to-guides/app-guides/migrate-dockerfile-to-direct-image-deploy) for more information.</Note>

## Deploying via Terraform

<Warning>Prerequisites: Install the [Aptible CLI](/docs/reference/aptible-cli/cli-commands/overview) and the Terraform CLI</Warning>

### 01: Create an app

[Apps](/docs/core-concepts/apps/overview) can be created using the **terraform** **`aptible_app`** resource.

```js theme={null}
resource "aptible_app" "APP" {
    env_id = ENVIRONMENT_ID
    handle = "APP_HANDLE"
}
```

### Step 2: Deploy a Docker Image

Set your Docker image and optional registry credentials as attributes on the `aptible_app` resource:

```hcl theme={null}
resource "aptible_app" "APP" {
    env_id = ENVIRONMENT_ID
    handle = "APP_HANDLE"
    docker_image = "quay.io/aptible/deploy-demo-app"
    private_registry_username = "registry_username"
    private_registry_password = "registry_password"
    config = {
        "KEY" = "value"
    }
}
```

<Note>Please ensure you have the correct image, username, and password set every time you run `terraform apply`. See [Terraform's refresh documentation](https://developer.hashicorp.com/terraform/cli/commands/refresh) for more information.</Note>

## Deploying via CI/CD

See related guide: [How to deploy to Aptible with CI/CD](/docs/how-to-guides/app-guides/how-to-deploy-aptible-ci-cd#deploying-with-docker)
