Skip to content

Commit

Permalink
add wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
mfranzon committed Nov 29, 2023
1 parent ae9d216 commit 4e442ec
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ We've provided a set of Dockerfiles covering common use cases. These Dockerfiles
- [Node.js Application](./docker-ready-to-go/node_container/)
- [Rust Application](./docker-ready-to-go/rust_container/)

## Docker Wasm

Simplest walkthrough in the web landscape to run a wasm container in Docker without pain and without Docker Desktop.

You just need four simple steps to run any wasm runtime.

- How to configure docker for wasm [here](./docker-wasm/).
- How to create a wasm image [COMING SOON]()

It works for real!🚀

## Contributing

We welcome contributions from the community! If you have a Docker tip, a useful Dockerfile, or an improvement to an existing one, feel free to open a pull request. Please make sure to follow our [contribution guidelines](CONTRIBUTING.md).
Expand Down
47 changes: 47 additions & 0 deletions docker-wasm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
## How to run a Docker wasm container

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

```json
{
"features": {
"containerd-snapshotter": true
}
}
```
Save, close and restart docker:

```bash
systemctl restart docker
```

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

```bash
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`

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

Last step, enjoy your docker wasm

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

0 comments on commit 4e442ec

Please sign in to comment.