# How to Access the Console for an App Platform Component App Platform is a fully managed Platform-as-a-Service (PaaS) that deploys applications from Git repositories or container images. It automatically builds, deploys, and scales components while handling all underlying infrastructure. The console of an App Platform component is an in-browser command-line terminal whose shell context is a running container instance for a given resource. You can connect to the console of your app’s components (services and workers) to run commands in the component’s container. By running commands in the console, you can see the active processes that are running inside the container, browse its local file system, monitor resource usage, observe system logs, and more. Connecting to the console is useful for troubleshooting issues, performing maintenance tasks, and running other one-off commands. This is similar to other container workflows involving logging into the virtualized environment. For example, with containers that have a `bash` shell, you can achieve the same effect locally by running `docker exec -it CONTAINER_ID /bin/bash`. **Warning**: Container environments are ephemeral, so any changes you make to your app or files in the container using the console do not persist. Additionally, there is no synchronization between containers, so changes you make in one container do not propagate to other containers. You can access the console for a component using the DigitalOcean Control Panel, [API](https://docs.digitalocean.com/reference/api/digitalocean/index.html.md), or the [official CLI](https://docs.digitalocean.com/reference/doctl/index.html.md), doctl. ## Access a Component’s Console Using the API ## How to Access the Console Using the DigitalOcean API 1. [Create a personal access token](https://docs.digitalocean.com/reference/api/create-personal-access-token/index.html.md) and save it for use with the API. 2. Send a GET request to [`https://api.digitalocean.com/v2/apps/{app_id}/components/{component_name}/exec`](https://docs.digitalocean.com/reference/api/digitalocean//index.html.md#operation/apps_get_exec_active_deployment). ### cURL Using cURL: ```shell curl -X GET \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ "https://api.digitalocean.com/v2/apps/{app_id}/components/{component_name}/exec" ``` ### Python Using [PyDo](https://github.com/digitalocean/pydo), the official DigitalOcean API client for Python: ```python import os from pydo import Client client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN")) get_resp = client.apps.get_exec_active_deployment(app_id="a6adf840", component_name="component") ``` ## Access a Component’s Console Using the CLI ## How to Access the Console Using the DigitalOcean CLI 1. [Install `doctl`](https://docs.digitalocean.com/reference/doctl/how-to/install/index.html.md), the official DigitalOcean CLI. 2. [Create a personal access token](https://docs.digitalocean.com/reference/api/create-personal-access-token/index.html.md) and save it for use with `doctl`. 3. Use the token to grant `doctl` access to your DigitalOcean account. ```shell doctl auth init ``` 4. Finally, run `doctl apps console`. Basic usage looks like this, but you can [read the usage docs](https://docs.digitalocean.com/reference/doctl/reference/apps/console/index.html.md) for more details: ```shell doctl apps console [flags] ``` The following example initiates a console session for the app with the ID `f81d4fae-7dec-11d0-a765-00a0c91e6bf6` and the component `web`: ```shell doctl apps console f81d4fae-7dec-11d0-a765-00a0c91e6bf6 web. To initiate a console session to a specific instance, append the instance id: doctl apps console f81d4fae-7dec-11d0-a765-00a0c91e6bf6 web sample-golang-5d9f95556c-5f58g ``` ## Access a Component’s Console Using the Control Panel To access a component’s console, go to the [**Apps** page](https://cloud.digitalocean.com/apps), select your app, then click the **Console** tab. On the **Console** page, select a component to open its console. ![A screenshot of a console open for an app component.](https://docs.digitalocean.com/screenshots/app-platform/app-console.7326be3835de725f101ee8a6392cdd65e375ef7b52e4e6e571cbdfb9fc7a8a25.png) ## Access a Specific Instance App Platform components can have multiple running instances. Whenever your app deploys or scales (automatically or manually), it creates a new instance. When accessing the app’s console, App Platform automatically connects you to the first available instance. However, you may want to access the console of another specific instance to debug an issue, using the DigitalOcean API or CLI. For example, if that instance is handling a significantly different workload. To get a list of an app’s running compute instances: ## CLI Run the following `doctl` command (requires version v1.129.0 or newer): ```bash doctl apps list-instances $app_id ``` ## API Use the following API call: ```c curl -X GET \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ "https://api.digitalocean.com/v2/apps/$app_id/instances" ``` This returns an array of component instances, each with an ephemeral `instance_name` property and `instance_alias` property [mappable to the app’s insights](https://docs.digitalocean.com/products/app-platform/how-to/view-insights/index.html.md). You can then use an instance’s name to get an exec URL: ## CLI Run the following `doctl` command (requires version v1.129.0 or newer): ```bash doctl apps console $app_id $component_name $instance_name ``` ## API Use the following API call: ```c curl -X GET \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ "https://api.digitalocean.com/v2/apps/{app_id}/deployments/{deployment_id}/components/{component_name}/exec?instance_name={instance_name}" ``` This returns an exec URL, which you can use to access the instance’s console using the [CLI](#access-a-components-console-using-the-cli) or [API](#access-a-components-console-using-the-api). We recommend [using Aptfile](https://docs.digitalocean.com/products/app-platform/reference/buildpacks/aptfile/index.html.md) to install tools. Because instances are ephemeral, do not make any changes to them that need to persist or create any scripts that rely on them.