DockerCon2022 Key Takeaways: Docker And WebAssembly

Joelchrist Abreu
Strategio
Published in
3 min readMay 13, 2022

What is Docker?

Docker is a platform used for developing, shipping, and running applications. It provides the ability to package and execute different services in an isolated environment called a container. They are lightweight and contain everything needed to run the service. The containers work the same way for every machine, so there is no worry that it will not work the same way. It also allows developers to push to testing environments and production environments quickly. Its portability and lightweight nature allow it to quickly scale and easily be torn down. This lightweight nature is ideal for high-density environments where you need to do more with fewer resources.

ScreenShot from https://docs.docker.com/get-started/overview/

Docker utilizes client-server architecture. The Docker client interacts with the Docker daemon, which builds, runs, and distributes your containers. The client can talk to the local daemon on your machine and a remote daemon. The client and the daemon communicate by using REST API over Unix sockets or a network interface.

What is WebAssembly?

WebAssembly (Wasm) is a binary instruction format for a stack-based virtual machine. Wasm is efficient and fast because it is designed to be encoded in size and load-time-efficient binary format. Its goal is to execute at native speeds by utilizing the common hardware capabilities in a range of platforms. Wasm is also debuggable since it is designed to be pretty printed in a textual format. This format allows for easy debugging, testing, optimization, and development. Wasm describes a memory-safe, sandboxed execution environment. It also enforces the same-origin and permissions security policies of the browser. WebAssembly adopts some aspects of the nature of the web. It is versionless, feature-tested, and backward compatible. The WebAssembly System Interface allows us to extend WebAssembly’s capabilities into the cloud space. Spin is a framework built on WebAssembly designed for building microservices.

How might we use them in conjunction?

We can utilize Docker to organize communication between different Wasm modules and invocations. Docker is also great for services with predictable loads and services that are meant to be run for a long period of time. A load balancer is a great example, its job is to direct traffic based on different criteria. If the load balancer piece of our architecture is not up and running, we won’t be able to successfully run our services.

Wasm can rapidly be initialized and can be quickly torn down. This is good to scale rapidly based on the demand for a service. Each of these services executes a simple task such as retrieval of information from a database. It aids companies in keeping resources down while demands are not high.

Use Case:

Play Finicky Whiskers at https://www.finickywhiskers.com/index.html

Finicky Whiskers is designed to showcase the power of WebAssembly in conjunction with Docker or other containerization services. Finicky Whiskers is a web-based game developed by Fermyon which utilizes a static front-end, Eight WebAssembly microservices, and Redis running in a Docker container. As a button is clicked to feed the cat, we are sending a request to Spin which initializes a new Wasm instance to handle a request. More clicks result in more instances to be initialized by spin. You can read more about the Spin framework at https://github.com/fermyon/spin.

--

--