Getting Started with WasmEdge on Docker Desktop: A Step-by-Step Guide
Getting Started with Docker + WasmEdge: A Step-by-Step Guide
The new version of Docker Desktop officially integrates WasmEdge
Docker Desktop has released a new version 4.15, which officially integrated WasmEdge's containerd shim, and Docker + Wasm also entered the beta stage from tech preview. This means that 10 million Docker Desktop users have installed WasmEdge, and Docker developers can use their familiar tool chain to develop WasmEdge applications.
Docker+WasmEdge provides a complete example of a database-based microservice application. To quickly try out Docker + Wasm, it is easiest to start with this example.
First, git clone to microservice-rust-mysql repository locally and open the example.
$ git clone https://github.com/second-state/microservice-rust-mysql.git
$ cd microservice-rust-mysql
Next, open Docker Desktop and ensure that it is running. You can download the latest Docker Desktop from here.
Next, use the command docker compose up
to build and run the microservice demo.
docker compose up
This command will build the image according to the Dokcerfile, which includes two Linux container images (Nginx and MariaDB) and one Wasm image, running Rust-based microservices.
Then docker will start the container according to docker-compose.yml
and run the built image.
After running, open http://localhost:8090/
in the browser, and you can see the web UI of this microservice. As shown in the UI, this microservice adds the front-end order information to the database through the Wasm-based microservice.
When checking Docker Desktop, there will be a total of three containers running, with one of them marked as Wasm32, indicating that it is a Wasm container.
There are three images, of which the Wasm image is only 3MB, the Linux-based nignx image 12MB, and the MariaDB image over 100MB. This shows how lightweighted Wasm is.
Not only is Wasm small in size, it is also high-performance, starting in milliseconds compared to hundreds of milliseconds for Linux containers.
It is worth mentioning that at the recent AWSre:Invent, a 60,000-person conference in North America, AWS released its snapstart product to reduce the cold start time to 600 milliseconds. However, without any optimization, the cold start time of Wasm based microservices and serverless functions can be in under millisecond. As the founder of Docker said, the future of cloud computing is WebAssembly on the server side.
In summary, we've learned how to use Docker Desktop and Docker compose to run Linux containers and Wasm containers side by side. In the next article, we will show you how to configure Dockerfile and docker-compose.yml. In future articles, we will guide you step by step on how to use the Docker toolchain to build your own Wasm applications from scratch.