Container snapshot and restore filesystem
Cloudflare Containers now support snapshot APIs in public beta, allowing developers to save and restore point-in-time filesystem state. Use snapshotContainer() to capture the full container filesystem and pass the snapshot handle to start() to restore files after container sleep, restart, or handoff to another Durable Object.
Containers now support snapshot APIs in public beta for saving and restoring point-in-time filesystem state. Create a snapshot first, then pass it back to start() to restore files after container sleep, restart, or handoff to another Durable Object.
Use snapshotContainer() through the Durable Object Container API to capture the full container filesystem. Create a snapshot from a running Container, store its handle, and pass that handle to start() when you restore it later:
import { DurableObject } from "cloudflare:workers";
export class MyDurableObject extends DurableObject {
async saveSnapshot() {
// Create a snapshot from the running Container.
const containerSnapshot = await this.ctx.container.snapshotContainer({});
await this.ctx.storage.put("containerSnapshot", containerSnapshot);
}
async restoreSnapshot() {
// Restore the saved snapshot later.
const containerSnapshot = await this.ctx.storage.get("containerSnapshot");
if (!containerSnapshot) {
return;
}
this.ctx.container.start({ containerSnapshot, enableInternet: false });
}
}src/index.tstsimport { DurableObject } from "cloudflare:workers";
export class MyDurableObject extends DurableObject {
async saveSnapshot() {
// Create a snapshot from the running Container.
const containerSnapshot = await this.ctx.container.snapshotContainer({});
await this.ctx.storage.put("containerSnapshot", containerSnapshot);
}
async restoreSnapshot() {
// Restore the saved snapshot later.
const containerSnapshot =
await this.ctx.storage.get<ContainerSnapshot>("containerSnapshot");
if (!containerSnapshot) {
return;
}
this.ctx.container.start({ containerSnapshot, enableInternet: false });
}
}
Snapshots are only supported for Container applications that use the durable_object scheduling policy. Snapshots are immutable, so create a new snapshot to persist filesystem changes made after a restore.
For more information, refer to Snapshots and the Durable Object Container API.
Source: original entry ↗
More from Cloudflare
Follow Cloudflare to get its new changes in your feed and email digest.
Cloudflare API MCP server now serves Cloudflare skills
The Cloudflare API MCP server now integrates with the Skills over MCP extension, allowing MCP clients to discover and access Cloudflare skills. Users can add the MCP server endpoint to compatible MCP clients to access these skills.
WAF failed detections field now available in Rules
A new cf.appsec.request.failed_detections field lets you control how rules handle requests when security detections fail. This array of detection IDs covers content scanning, WAF attack scoring, attack signatures, leaked credentials, and AI-based PII/prompt injection/custom topic detection failures, and works across custom rules, rate limiting rules, and request header transform rules.
Markdown for Agents: More efficient in-process streaming conversion
Markdown for Agents now uses an in-process streaming engine at the edge to convert HTML, reducing overhead and memory use. The conversion limit increased from 2 MiB to 6 MiB, and token count headers are no longer generated.