pydo.microvms.run_command()

Generated on 13 Nov 2026 from pydo version v0.46.0

Usage

client.microvms.run_command(
    microvm_id="01a0ef1a-d873-793d-ae6a-5dd6239be62a",
    body={
        "argv": [...],
        "cwd": "/usr/share/nginx/html",
        "output_encoding": "utf-8",
    },
)
Returns JSON Raises HttpResponseError

Description

To run a command in a MicroVM’s workload container, send a POST request to /v2/microvms/{microvm_id}/exec.

argv runs directly, not through a shell, with standard input closed. If the MicroVM is paused and auto-resume is on, the request resumes it and waits until it is running.

A command has 60 seconds to finish. Your team can run 32 commands at once and 60 commands per minute. Rejected requests count toward the per-minute limit.

Parameters

microvm_id string required

The unique ID of the MicroVM.

argv array of strings required

Example: ['nginx', '-v']

The command and its arguments.

cwd string optional

Example: /usr/share/nginx/html

The working directory to run the command in.

output_encoding string optional

How stdout and stderr are returned. utf-8 (the default) is a JSON string; bytes that are not valid UTF-8 become U+FFFD. base64 returns the exact bytes. Use base64 when the command may emit binary output.

One of: utf-8, base64

Default: utf-8

Request Sample

Show Request Sample
import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

req = {
  "argv": [
    "nginx",
    "-v"
  ]
}

resp = client.microvms.run_command(microvm_id="01a0ef1a-d873-793d-ae6a-5dd6239be62a", body=req)

Response Example

Show Response Example
{
  "stdout": "",
  "stderr": "nginx version: nginx/1.29.1\n",
  "exit_code": 0
}

More Information

See /v2/microvms/{microvm_id}/exec in the API reference for additional detail on responses, headers, parameters, and more.

We can't find any results for your search.

Try using different keywords or simplifying your search terms.