Runtime & Platform
Runtimes and platforms define the virtualization, operating system, and CPU architecture of the compute you run on Modal.
Runtime
A runtime is the virtualization and sandboxing technology used to run a Sandbox on a Modal Worker host. Runtimes are responsible for exposing operating system APIs, isolating Sandboxes from the host and other tenants, and for providing high performance.
Sandboxes run on one of two runtimes:
- gVisor, a container runtime developed by Google, provides strong isolation and is suitable for most workloads.
- VMs run the Sandbox in a virtual machine with its own Linux kernel. Use the VM runtime for workloads that expect a full Linux environment, such as running Docker inside the Sandbox, mounting FUSE filesystems, or managing resources with nested cgroups.
Switch runtimes via the runtime parameter, or leave unset to let Modal choose for you.
sb = modal.Sandbox.create(app=sb_app, runtime="vm") # or: runtime="gvisor"
p = sb.exec("uname", "-srn")
print(p.stdout.read()) # Linux modal 7.2.6
sb.terminate()const sb = await modal.sandboxes.create(app, image, { runtime: "vm" });
const p = await sb.exec(["uname", "-srn"]);
console.log(await p.stdout.readText()); // Linux modal 7.2.6sb, err := mc.Sandboxes.Create(ctx, app, image, &modal.SandboxCreateParams{
Runtime: modal.SandboxRuntimeVM,
})
p, err := sb.Exec(ctx, []string{"uname", "-srn"}, nil)
stdout, err := io.ReadAll(p.Stdout)
fmt.Println(string(stdout)) // Linux modal 7.2.6Choosing a runtime
The Modal SDK will select the optimal or required runtime based on your Sandbox’s specification. For example, GPU Sandboxes are currently only supported with runtime="gvisor".
On the other hand, for running Docker in your application, we advise selecting the VM runtime.
Running Docker in a Sandbox
Use the VM runtime to run Docker in a Sandbox. Start dockerd as the Sandbox entrypoint and run containers with sb.exec. Containers on the Docker bridge can reach each other, and /var/lib/docker is included in Filesystem Snapshots.
# The named Image has Docker installed. It was built and published ahead of time:
#
# image = (
# modal.Image.from_registry("ubuntu:24.04")
# .env({"DEBIAN_FRONTEND": "noninteractive"})
# .apt_install("docker.io")
# )
# image.build(sb_app).publish("sandbox-docker")
sb = modal.Sandbox.create(
"dockerd",
app=sb_app,
# prefer named Images in Sandboxes to ensure they are never built during Sandbox launch
image=modal.Image.from_name("sandbox-docker"),
runtime="vm",
readiness_probe=modal.Probe.with_exec("docker", "info", interval_ms=500),
)
sb.wait_until_ready()
p = sb.exec("docker", "run", "--rm", "alpine", "echo", "hello from Docker")
p.wait()
print(p.stdout.read())
sb.terminate()import { Probe } from "modal";
const dockerImage = modal.images
.fromRegistry("ubuntu:24.04")
.dockerfileCommands([
"ENV DEBIAN_FRONTEND=noninteractive",
"RUN apt-get update && apt-get install -y docker.io",
]);
const sb = await modal.sandboxes.create(app, dockerImage, {
command: ["dockerd"],
runtime: "vm",
readinessProbe: Probe.withExec(["docker", "info"], {
intervalMs: 500,
}),
});
await sb.waitUntilReady();
const p = await sb.exec(
["docker", "run", "--rm", "alpine", "echo", "hello from Docker"],
{ stdout: "pipe" },
);
await p.wait();
console.log(await p.stdout.readText());
await sb.terminate();dockerImage := mc.Images.FromRegistry("ubuntu:24.04", nil).DockerfileCommands([]string{
"ENV DEBIAN_FRONTEND=noninteractive",
"RUN apt-get update && apt-get install -y docker.io",
}, nil)
probe, _ := modal.NewExecProbe(
[]string{"docker", "info"},
&modal.ExecProbeParams{Interval: 500 * time.Millisecond},
)
sb, _ := mc.Sandboxes.Create(ctx, app, dockerImage, &modal.SandboxCreateParams{
Command: []string{"dockerd"},
Runtime: modal.SandboxRuntimeVM,
ReadinessProbe: probe,
})
sb.WaitUntilReady(ctx, 5*time.Minute, nil)
p, _ := sb.Exec(ctx, []string{
"docker", "run", "--rm", "alpine", "echo", "hello from Docker",
}, &modal.SandboxExecParams{Stdout: modal.Pipe})
p.Wait(ctx, nil)
stdout, _ := io.ReadAll(p.Stdout)
fmt.Println(string(stdout))
sb.Terminate(ctx, nil)Nested virtualization
Nested virtualization lets you run a hypervisor inside a virtual machine (VM), so that a VM runtime Sandbox can host its own guest VMs.
Nested virtualization is available for select customers on the Enterprise plan by setting the "enable_nested_virt" experimental option on a VM Sandbox.
modal.Sandbox.create(
app=sb_app,
runtime="vm",
experimental_options={"enable_nested_virt": True},
)Platform
A platform defines an operating system (OS) and CPU architecture pair.
Certain applications require a specific operating system, for example Microsoft Access requires Windows. By contrast, cross-platform software needs to be built and tested across multiple operating systems and architectures.
Modal adopts the standard platform tagging scheme used by Docker and gVisor, and supports the following platforms:
linux/amd64(default)linux/arm64windows/amd64
To select a platform, specify the platform= argument with a supported platform tag during modal.Image creation.
img = modal.Image.from_registry("python:3.12-slim", platform="linux/arm64")Availability
The vast majority of Modal host compute capacity is linux/amd64 and thus scheduling rate limits, burst allowances, and concurrency limits are highest on that platform.
Platform Billing
Platforms use different pricing due to differences in underlying hardware cost and OS licensing fees.
See Pricing for details.