liveBook · Manning

Container image

As explained in Server-Side WebAssembly

A container image is an immutable package containing an application, its dependencies, and the filesystem metadata needed to create a container.

A container image is an immutable package used to create containers. It bundles an application with the userspace environment, system libraries, utilities, and configuration needed to run it through a container engine. section 7.1

A Dockerfile defines how an image is assembled: choose a base image, copy application files, install dependencies, expose ports, and set the command to execute. Building the Dockerfile produces a local image that can then be run or converted. section 7.6.3 section 7.3

Container images and Wasm packages distribute different things:

  • A conventional container image commonly includes application code plus a userspace environment and system dependencies. section 7.1
  • A Wasm binary packages application logic and relies on WASI and a Wasm runtime for a portable system interface. section 7.1
  • The additional environment makes even minimal container images typically megabyte-scale, while Wasm binaries are often measured in kilobytes and can start with less initialization overhead. section 7.1
  • A container image built for one CPU architecture requires a multiarchitecture image to run on another architecture such as ARM instead of AMD. section 7.1
Figure 7.1 The typical architecture of a containerized system, illustrating how applications are packaged with their dependencies and userspace environment, all managed by the Docker engine on top of the host operating system
A screenshot of a black screen

AI-generated content may be incorrect.

This architecture view shows the image packaging application dependencies and userspace above the Docker engine and host operating system. section 7.1

Package and convert a Flask server

Start from python:3.9-slim, install Flask, copy app.py, expose port 8000, and run python app.py. Build the image as python-wasm-webserver, then use container2wasm to create python-wasm-webserver.wasm. Run it through c2w-net to proxy port 8000 and request the server with curl. section 7.6.3

Create a minimal Wasm container image

Compile a Rust application for wasm32-wasip1, then use a Dockerfile with FROM scratch to copy the .wasm file and declare it as ENTRYPOINT. The empty base image reflects that the Wasm binary does not require an operating system inside the image. section 7.3

How Server-Side WebAssembly covers it

How deep it goes
Explains image contents, architecture and CPU portability, then works through Dockerfile-based building and conversion without container-engine internals.
Examples
Uses a Python Flask server built from python:3.9-slim and a Rust Wasm program packaged from scratch.
What it assumes
Requires Docker for image execution while introducing Dockerfile instructions and a minimal Rust packaging workflow step by step.
What you can do after
Build it from scratch with a Dockerfile, or apply container2wasm to convert a local image into a runnable Wasm binary.
How it connects
Connects Docker, Dockerfiles, userspace environments, WASI, Wasmtime, WebAssembly, and container2wasm.

Also explained in

Compare how 25 books explain container image →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Server-Side WebAssembly. The section links point to the parts of the book it draws on.