Allow fetching unmodified container images to browser and running them #200
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The following description is outdated. Please see https://github.com/ktock/container2wasm/tree/main/extras/imagemounter instead.
This commit enables distributing unmodified container images and running it on browser, etc. (still with CPU emulation, though).
imagemounter
is a helper tool that enables to pull unmodified container images and mount it into the Linux VM running on Wasm.The benefits of this approach are that it eliminates the need for image conversion and allows the distributing unmodified container images directly from the container registry to the browser (but the registry needs to enable CORS).
The following tools are used:
c2w --external-bundle out.wasm
. This contains runc but doesn't embed container image. External container image's rootfs needs to be mounted to the VM via 9p.imagemounter.wasm
: This provides functionallity of pulling container images from remote location into the browser/node, and show the rootfs to the above Wasm image via 9p.Supported image sources
As of now, the following image server is supported:
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: *
Access-Control-Expose-Headers: Content-Range
Examples
First, build basic dependencies:
Example on browser + HTTP Server
The following pulls
ubuntu:22.04
stored at https://ktock.github.io/ubuntu-oci-images/ubuntu-22.04-org-amd64 as OCI Image Layout and runs it on Wasm.Then access to:
localhost:8083?image=https://ktock.github.io/ubuntu-oci-images/ubuntu-22.04-org-amd64
Example on browser + Registry
First, launch a registry with enabling CORS.
The above registry serves
localhost:5000/ubuntu:22.04
container image.The following serves a page to run that image.
When you access to
localhost:8083?image=localhost:5000/ubuntu:22.04
, that page fetcheslocalhost:5000/ubuntu:22.04
container image from the local registry and launches it on browser.