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).
How to Detach and Delete Volumes
Last verified 24 Nov 2026
Volumes are network-attached block storage. You can use them with Droplets, use Standard volumes with Kubernetes clusters, and move, resize, or snapshot them at any time.
To remove a volume from a Droplet, you can either:
Detach the volume, which removes it from the Droplet, but keeps the volume and its data so you can reattach it to another Droplet at any time.
Delete a volume, which permanently removes the volume and all of its data. This option cannot be undone, and you’re no longer billed for the volume.
If you remove a volume from a running Droplet, you may lose data or cause errors on your Droplet. First, turn off the Droplet, or make sure it’s not writing to the volume. You can check whether the volume is in use by listing open files on the mount point with lsof.
# Attach a Volume to a Droplet by IDcurl -X POST \
-H "Content-Type: application/json"\
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN"\
-d '{"type": "attach", "droplet_id": 11612190, "region": "nyc1", "tags":["aninterestingtag"]}'\
"https://api.digitalocean.com/v2/volumes/7724db7c-e098-11e5-b522-000f53304e51/actions"# Remove a Volume from a Droplet by IDcurl -X POST \
-H "Content-Type: application/json"\
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN"\
-d '{"type": "detach", "droplet_id": "11612190", "region": "nyc1"}'\
"https://api.digitalocean.com/v2/volumes/7724db7c-e098-11e5-b522-000f53304e51/actions"# Resize a Volumecurl -X POST \
-H "Content-Type: application/json"\
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN"\
-d '{"type":"resize","size_gigabytes": 100, "region":"nyc1"}'\
"https://api.digitalocean.com/v2/volumes/7724db7c-e098-11e5-b522-000f53304e51/actions"
Go
Using Godo, the official DigitalOcean API client for Go:
import("context""os""github.com/digitalocean/godo")funcmain(){token:=os.Getenv("DIGITALOCEAN_TOKEN")client:=godo.NewFromToken(token)ctx:=context.TODO()// Attach a Volume to a Droplet by IDaction,_,err:=client.StorageActions.Attach(ctx,"7724db7c-e098-11e5-b522-000f53304e51",11612190)// Remove a Volume from a Droplet by ID// action, _, err := client.StorageActions.Detach(ctx, "7724db7c-e098-11e5-b522-000f53304e51")// Resize a Volume// action, _, err := client.StorageActions.Resize(ctx, "7724db7c-e098-11e5-b522-000f53304e51", 100, "nyc1")}
Ruby
Using DropletKit, the official DigitalOcean API client for Ruby:
require'droplet_kit'token=ENV['DIGITALOCEAN_TOKEN']client=DropletKit::Client.new(access_token:token)# Attach a Volume to a Droplet by IDclient.volume_actions.attach(volume_id:'7724db7c-e098-11e5-b522-000f53304e51',droplet_id:11612190,region:'nyc1'# Remove a Volume from a Droplet by ID# client.volume_actions.detach(volume_id:'7724db7c-e098-11e5-b522-000f53304e51', droplet_id: 11612190, region: 'nyc1'
Python
Using PyDo, the official DigitalOcean API client for Python:
To detach a volume, go to the Volumes page and find the volume you want to detach. Open its … (More) menu, and then click Detach from Droplet to open the Detach Volume window.
If you detach an auto-mounted volume, you should also delete the corresponding systemd mount unit file from the Droplet, which is located at /etc/systemd/system/mnt-volume_*.mount. To do this, remove the file using rm, and then reload the systemd configuration with systemctl daemon-reload.
After detaching a volume, you can access it from the Volumes page. You continue to be billed for the volume until you delete it.
Delete a Volume Using Automation
You can delete volumes via the DigitalOcean CLI or API.
Delete a Volume via the CLI
To delete a volume via the CLI, use doctl compute volume delete and specify the ID or name of the volume you want to remove.
When you delete a volume, the volume and its contents are deleted. Deleting a volume is irreversible.
To delete a volume, go to the Volumes page, then find the volume you want to delete, open its … (More) menu, and then click Delete to open the confirmation window.
Then, enter the volume’s name, and click Delete Volume to delete the volume.
We can't find any results for your search.
Try using different keywords or simplifying your search terms.