|
| 1 | +# Setup Docker + Wasm |
| 2 | + |
| 3 | +If you are using Docker Desktop for Windoes/MacOS/Linux, please refer to this [document](https://docs.docker.com/desktop/wasm/) on turning on wasm intergration in Docker Desktop. This is the easiest way to get started with wasm shims. |
| 4 | + |
| 5 | +The more important part is to enable `containerd` for pulling and storing images in Docker Desktop. Refer this [document](https://docs.docker.com/desktop/containerd/#enabling-the-containerd-image-store-feature) for more details. |
| 6 | + |
| 7 | +This document is primarily for those who are using Docker daemon on Linux. |
| 8 | + |
| 9 | +## Install Docker 24.0.0-beta.2 |
| 10 | + |
| 11 | +Before you install Docker 24.0.0-beta.2, please uninstall docker tools you have installed on your machine. Please see this [document](https://docs.docker.com/engine/install/ubuntu/) for more details. |
| 12 | + |
| 13 | +```shell |
| 14 | +sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras |
| 15 | +``` |
| 16 | + |
| 17 | +After you have uninstalled docker tools, please install Docker 24.0.0-beta.2. |
| 18 | + |
| 19 | +```shell |
| 20 | +curl -fsSL https://get.docker.com -o get-docker.sh |
| 21 | + |
| 22 | +sudo CHANNEL=test sh get-docker.sh |
| 23 | +``` |
| 24 | + |
| 25 | +This will install Docker 24.0.0-beta.2 on your machine. |
| 26 | + |
| 27 | +To verify the installation, please run the following command. |
| 28 | + |
| 29 | +```shell |
| 30 | +docker version |
| 31 | + |
| 32 | +> Docker version 24.0.0-beta.2 |
| 33 | +``` |
| 34 | + |
| 35 | +Now you have Docker 24.0.0-beta.2 installed on your machine. Next step, we will need to edit the `/etc/docker/daemon.json` file to enable `containerd` for pulling and storing images in Docker Desktop. |
| 36 | + |
| 37 | +If you don't have `/etc/docker/daemon.json` file, please create one. |
| 38 | +```json |
| 39 | +{ |
| 40 | + "features": { |
| 41 | + "containerd-snapshotter": true |
| 42 | + } |
| 43 | +} |
| 44 | +``` |
| 45 | + |
| 46 | +Otherwise, please append the above content to the file. |
| 47 | + |
| 48 | +## Build wasm images |
| 49 | + |
| 50 | +Now you have Docker 24.0.0-beta.2 installed on your machine, you can build wasm images using the following command. |
| 51 | + |
| 52 | +```shell |
| 53 | +cd deployments/k3d |
| 54 | +docker buildx build --platform=wasi/wasm --load -t wasmtest_spin:latest ../../images/spin |
| 55 | +``` |
| 56 | + |
| 57 | +The `wasi/wasm` platform specifies that the image is a wasm image. The major benefit of using this platform is that you don't need to build each image for a different computer architecture. |
| 58 | + |
| 59 | +The `--load` flag tells Docker to load the image into the local Docker daemon. As described in this [issue](https://github.com/deislabs/containerd-wasm-shims/issues/87), this flag actually doesn't work for wasi/wasm platform. You will need to save the image to a tar file and load it into the local Docker daemon. |
| 60 | + |
| 61 | +```shell |
| 62 | +docker save wasmtest_spin:latest -o wasmtest_spin.tar |
| 63 | +``` |
| 64 | + |
| 65 | +### Load the image to k3d |
| 66 | + |
| 67 | +Refer to this [document](https://github.com/deislabs/containerd-wasm-shims/tree/main/deployments/k3d#how-build-get-started-from-source) to create a k3d cluster. |
| 68 | + |
| 69 | +Assume you have a k3d cluster named `k3d-default`, you can load the image to the cluster using the following command. |
| 70 | + |
| 71 | +```shell |
| 72 | +k3d image load wasmtest_spin.tar |
| 73 | +``` |
0 commit comments