Skip to content

Latest commit

 

History

History

docker-wasm

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

How to run a Docker wasm container

Step zero is creating/modifing your /etc/docker/daemon.json file, adding this feature:

{
  "features": {
    "containerd-snapshotter": true
  }
}

Save, close and restart docker:

systemctl restart docker

First step is compiling the containerd-shim-wasmtime that we will use later as runtime in docker.

docker build --output . - <<EOF
FROM rust:1.70.0 as build
RUN apt-get update -y
RUN apt-get install protobuf-compiler libdbus-1-dev pkg-config -y
RUN cargo install \
    --git https://github.com/mfranzon/runwasi.git \
    --branch oci-artifacts \
    --bin containerd-shim-wasmtime-v1 \
    --root /out \
    containerd-shim-wasmtime
FROM scratch
COPY --from=build /out/bin /
EOF

Second step, move the executable into an exported PATH like /usr/local/bin

mv ./containerd-shim-wasmtime-v1 /usr/local/bin

Last step, enjoy your docker wasm

docker run --runtime=io.containerd.wasmtime.v1 --platform wasi/wasm32 rumpl/wasmtest echo 'hello from wasm'