For AI agents: The documentation index is at https://docs.digitalocean.com/llms.txt. Markdown versions of pages use the same URL with index.html.md in place of the HTML page (for example, append index.html.md to the directory path instead of opening the HTML document).
Delete a Custom Image using the Automation
How to Delete a Custom Image Using the DigitalOcean CLI
- Install
doctl, the official DigitalOcean CLI.
- Create a personal access token and save it for use with
doctl.
- Use the token to grant
doctl access to your DigitalOcean account.
- Finally, run
doctl compute image delete. Basic usage looks like this, but you can read the usage docs for more details:
doctl compute image delete <image-id> [flags]
The following example deletes an image with the ID 386734086:
doctl compute image delete 386734086
How to Delete a Custom Image Using the DigitalOcean API
- Create a personal access token and save it for use with the API.
- Send a DELETE request to
https://api.digitalocean.com/v2/images/{image_id}.
cURL
Using cURL:
curl -X DELETE \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
"https://api.digitalocean.com/v2/images/7938391"
Go
Using Godo, the official DigitalOcean API client for Go:
import (
"context"
"os"
"github.com/digitalocean/godo"
)
func main() {
token := os.Getenv("DIGITALOCEAN_TOKEN")
client := godo.NewFromToken(token)
ctx := context.TODO()
_, err := client.Images.Delete(ctx, 7938391)
}
Ruby
Using DropletKit, the official DigitalOcean API client for Ruby:
require 'droplet_kit'
token = ENV['DIGITALOCEAN_TOKEN']
client = DropletKit::Client.new(access_token: token)
client.images.delete(id: 7938391)
Python
Using PyDo, the official DigitalOcean API client for Python:
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
resp = client.images.delete(image_id=134215)
Delete a Custom Image using the Control Panel
To delete a custom image via the control panel, in the left menu, click Backups & Snapshots, then click the Custom Images tab.
Click the More menu for the custom image you want to delete, then choose Delete. A confirmation window titled Confirm delete item opens. Click Delete Item to confirm the deletion
Droplets you’ve created from a custom image are not deleted when you delete the image from your account. You can destroy Droplets from the control panel separately.