Docker’s WASM integration is currently a beta feature available in a special technical-preview build of Docker Desktop. Refer to Docker’s experimental WASM support when testing locally.
Prerequisites
1. Write a simple C program
Create a file namedhelloworld.c:
2. Compile to a WASM binary
Use the WASI SDK’s Clang to targetwasm32-wasi:
helloworld.wasm in your working directory.
3. Create the Dockerfile
We’ll build FROM scratch so the final image only contains the WASM binary:Dockerfile alongside helloworld.wasm.
4. Build the Docker image
Run:The
--platform=wasm/wasm32 flag instructs Docker to treat this as a WASM container.