How to Delete Custom Images

Custom images are Linux and Unix-like images you import to DigitalOcean. You can create Droplets based custom images, which lets you migrate and scale your workloads without spending time recreating your environment from scratch.


Delete a Custom Image using the Automation

How to delete a custom image using the DigitalOcean CLI

To delete a custom image via the command-line, follow these steps:

  1. Install doctl, the DigitalOcean command-line tool.

  2. Create a personal access token, and save it for use with doctl.

  3. Use the token to grant doctl access to your DigitalOcean account.

                  doctl auth init
                
  4. Finally, delete a custom image with doctl compute image delete. The basic usage looks like this, but you'll want to 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

To delete a custom image using the DigitalOcean API, follow these steps:

  1. Create a personal access token, and save it for use with the API.

  2. Send a DELETE request to https://api.digitalocean.com/v2/images/{image_id}

    cURL

    To delete a custom image with cURL, call:

    
                    curl -X DELETE \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
      "https://api.digitalocean.com/v2/images/7938391"

    Go

    Go developers can use Godo, the official DigitalOcean V2 API client for Go. To delete a custom image with Godo, use the following code:

    
                    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

    Ruby developers can use DropletKit, the official DigitalOcean V2 API client for Ruby. To delete a custom image with DropletKit, use the following code:

    
                    require 'droplet_kit'
    token = ENV['DIGITALOCEAN_TOKEN']
    client = DropletKit::Client.new(access_token: token)
    
    client.images.delete(id: 7938391)

    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, click Images in the main navigation, then click the Custom Images tab.

Custom Images tab in the control panel

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.