Search⌘ K

Containerize a Wasm App

Explore how to containerize WebAssembly applications using Docker Desktop. Learn to create Dockerfiles tailored for Wasm apps, update configuration files, build and tag Wasm images, push to OCI registries, and run containers with the spin runtime. This lesson equips you to deploy Wasm apps as portable, lightweight containers.

Docker Desktop lets you containerize Wasm apps so you can use familiar Docker tools to push and pull them to OCI registries and run them inside containers.

Creating a Dockerfile

As always, we need a Dockerfile that tells Docker how to package the app as an image. Create a new file called Dockerfile in your hello-world directory and populate it with the following three lines.

FROM scratch
COPY /target/wasm32-wasi/release/hello_world.wasm .
COPY spin.toml .
Creating a Docker image with the Wasm application

The file references a special empty base image called scratch because Wasm containers don’t need a Linux OS.

The two COPY ...