Use snapshots

Last updated Sep 30, 2026 Snapshots let you save point-in-time filesystem state from a running Container. The examples on this page use the Durable Object Container API.

Scheduling policy requirement

Snapshots are only supported by Container applications that use the durable_object scheduling policy. Applications that use the default scheduling policy cannot create or restore snapshots.

Create a container snapshot

Use snapshotContainer() to capture the full container filesystem. Snapshots are immutable. If you restore a snapshot and then change files, create a new snapshot to persist those changes.

Snapshot image compatibility

Snapshots capture the Container's complete filesystem state, but not its memory or running processes. A snapshot is tied to the Container image version it was created from and is not portable to a different image. After updating the image, create a new snapshot from a Container running that image.

The returned snapshot handle is a plain data object. You can store it and restore it later, including from another Durable Object:

src/index.jsjs

import { DurableObject } from "cloudflare:workers";

export class MyDurableObject extends DurableObject {
    async saveContainer() {
        const containerSnapshot = await this.ctx.container.snapshotContainer({
            name: "before-upgrade",
        });

        await this.ctx.storage.put("containerSnapshot", containerSnapshot);
    }
}

src/index.tsts

import { DurableObject } from "cloudflare:workers";

export class MyDurableObject extends DurableObject {
    async saveContainer() {
        const containerSnapshot = await this.ctx.container.snapshotContainer({
            name: "before-upgrade",
        });

        await this.ctx.storage.put("containerSnapshot", containerSnapshot);
    }
}

Restore a container snapshot

Load the saved snapshot handle. Then, pass it to this.ctx.container.start() when you start another container:

src/index.jsjs

import { DurableObject } from "cloudflare:workers";

export class MyDurableObject extends DurableObject {
    async restoreContainer() {
        const containerSnapshot = await this.ctx.storage.get("containerSnapshot");

        if (!containerSnapshot) {
            return;
        }

        this.ctx.container.start({ containerSnapshot, enableInternet: false });
    }
}

src/index.tsts

import { DurableObject } from "cloudflare:workers";

export class MyDurableObject extends DurableObject {
    async restoreContainer() {
        const containerSnapshot =
            await this.ctx.storage.get<ContainerSnapshot>("containerSnapshot");

        if (!containerSnapshot) {
            return;
        }

        this.ctx.container.start({ containerSnapshot, enableInternet: false });
    }
}

Understand retention

Snapshots have an implicit 30-day time-to-live. Each restore refreshes that time-to-live.

You cannot set a custom time-to-live yet.

Was this helpful?

YesNo

On this page

Use snapshots - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/containers/guides/snapshots/#page","headline":"Use snapshots","description":"Save and restore Container filesystems with the Durable Object scheduling policy.","url":"https://developers.cloudflare.com/containers/guides/snapshots/","inLanguage":"en","image":"https://developers.cloudflare.com/containers/guides/snapshots/og.png?v=74144dfc758483da","dateModified":"2026-09-30","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}


description: Connect to running container instances with SSH. title: SSH image: https://developers.cloudflare.com/containers/guides/ssh/og.png?v=4c9d3eebfeaea9f5


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/containers/llms.txt
Use this file to discover all available pages before exploring further.