The Docker+WASM Technical Preview
docker.com
docker.com
Judging by the reception at KubeCon & elsewhere today, we think at least some folks are excited by it. But it’s still early, and who knows, you may be right in the end. We launched this as a technical preview to test a hypothesis and learn from it, and so far the interactions from this HN thread alone have been greatly helpful.
Is the intention to containerize WASM binaries and manage them with Docker like you would any other container?
Genuine questions, I'm just trying to understand what this feature is and why someone would want to use it.
The article linked by the OP has the correct links.
> which allows you to build both traditional container apps, as well as Wasm apps
I can already do that. Using Rust for the sake of example: `cargo build` can give me a WASM binary, and `docker build` can give me a container. Is Docker+WASM going to replace `cargo build`? Or is it going to wrap the WASM binary produced by cargo in another layer of abstraction? If the latter, how is this new layer of abstraction different from just using one of the WasmEdge docker containers [0]?
I'm not trying to be combative, I'm just sincerely confused at what problem this technical preview is intended to solve.
[0] https://wasmedge.org/book/en/quick_start/use_docker.html
This is all good feedback, and we’ll definitely try to explain the added value better in the future. The main advantages we see in this technical preview are:
1. Easy, reproducible dev environment to quickly & reliably develop cloud/edge apps that target Wasm, or code frontend apps that target a Wasm backend (for example, as part of a microservice architecture). This is particularly helpful if you build apps that have a mix of Wasm & container components[0]
2. Easy way to share & deploy Wasm artifacts, using trusted infra like Docker Hub, but also Dockerfiles and Docker Compose
3. Transparent, reliable way to deploy Wasm applications to existing container-based infrastructure such as k8s (via OCI images) — but these apps can also be “unpacked” to run natively on edge infrastructure
> is it going to wrap the WASM binary produced by cargo in another layer of abstraction? If the latter, how is this new layer of abstraction different from just using one of the WasmEdge docker containers [0]?
Our approach is close to this. First, it was built with the WasmEdge folks, so you’re correct to detect the similarity. Second, it does wrap resulting artifacts into a OCI image, because we believe that can generate a lot of advantages (points #2 and #3 above) BUT you can also easily unpack the Wasm payload from the binary image at deploytime/runtime if you’d rather deploy your app on Wasm-native infrastructure (as opposed to container-native infra)
Appreciate the feedback. Hope the above helps.
[0]: https://docs.docker.com/desktop/wasm/#running-a-multi-servic...
And, this tech is so general that there’s a second trap of “What can it do? It can do anything! Sure, but what can it do??” Again, because I’m your head “anything” is pre-supposed to a narrow set of goals that this tech fulfills very nicely. It cannot, for example, take my dog for a walk. So, it can’t do “anything” ;p It’s hard to get out of that head-space because you’ve been so deep in it for so so long.
But, I and 85% of people here have no idea what narrow set of goals Docker+Wasm fulfills. Something about apps and security something something. Mostly for servers probably.
Some awesome-fit exemplar use cases would help a lot.
My best guess is that Tim is trying to say, "now can run your Docker apps on AWS Lambda"?
> the "main advantages" [redacted] describes are the same as Docker
Yup, that’s it! If you value Docker to build container apps, we think this will help you build Wasm apps in the same way, and the only container-centric abstraction this Technical Preview uses (packaging artifacts as OCI images) can be bypassed, if you prefer to deploy your artifacts as native Wasm binaries. The latter can be helpful if you are trying to get the full speed & efficiency benefits of a Wasm-native deployment, as the shim in our OCI package introduces a small performance penalty.
[0]: https://aws.amazon.com/blogs/containers/containerizing-lambd...
"Docker images can now be deployed directly to the WASM runtime! This means your AWS Lambdas, Cloudflare Workers, etc. will boot faster and cost less..."
When you rehash what Docker already does, it's watering down the messaging. Even adding "AWS announced support for containers on Lambda last year" in the last reply made the voice in my head ask again, "What's different about it? How is it better?"
What you can however, is build apps for Wasm (or apps that combine Wasm and containers) with the same ease you currently enjoy when building pure container apps, i.e. see my comment above [0]
If I have a rust app on a scratch image, why would I want to turn it into a wasm container?
My assumption is because wasm can run on multiple platforms (x86 and arm) so one image supports both, is that correct? Are there other reasons not as obvious?
Really? I would not have expected that. Is that just under the assumption that most apps have an underlying OS (like alpine) and aren't on a scratch container?
what are the limitations of this? ok, for example can you deploy postgres on the browser with this? can you have a full OS container running on the browser with this, say ubuntu shell frontend with some javascript and an ubuntu container running on the browser?
The first impression from 'Docker + WASM' surely sounds like that is what it is, but after about 30 mins, I am not so sure that is actually the case.
It sounds like you're anticipating a new market segment for artifact deployment and want to be its primary service provider.
And I guess dockerfile can serve as a wasm-playlist for stuffing a whole bunch of them in one container? Call it wasm-spotify
You are going to lose this battle because your Dev Environments don't have a lot of buy-in and you're not standardized and open specced. I'd love to see Docker take a more OSS-friendly approach.
In Compose, the "server" service is running using the image that is produced by that build. It's then handed off to the new Wasm runtime, where the module is extracted and executed. Hope that helps! Feel free to follow up with more questions!
If this is the case I'd leave docker outside the name of the technology. I imagine the confusion. At least one customer of mine doesn't fully get the difference between a docker image and a VM yet, after years they are using docker in production.
With this preview, we are leveraging the OCI specification that defines how to build an image. Linux/Windows containers are the most common use of this specification, but many other types of artifacts exist (OPA policies, Helm charts, etc.).
When using any of these other artifact types, tooling has to know how to use that specific artifact type and run it (eg, extract the image and run it as a container or extract the Helm chart and deploy it). In our Wasm use case, we are doing the same thing... package and ship a Wasm module and we'll extract it and run it on the new Wasm runtime. That runtime then "converts" the Wasm module into native machine code for the OS you're running on.
> If this is the case I'd leave docker outside the name of the technology. I imagine the confusion.
That's great feedback! While most know us as "the container company", our mission doesn't even talk about containers. We want to help all developers succeed by reducing app complexity. We can certainly do more to help educate folks between the different types of workloads you might be running. We're still very early on in this process, so stay tuned (and keep the feedback coming)!
Like if you have any docker container, you can now take that, with some modification and run that directly on the browser. Reading further, I think this is totally not what it actually is.
You could say 'Docker for WASM applications' or 'Docker to deploy WASM apps' that would make the relationship more clear I think.
How about getting docker running in WASM so I can run containers in the browser?
I guess it’s a wasm runner
At the heading “How do I get the technical preview?” I was expecting a heading that says “What is Docker+WASM?”
Glad I am not the only one
Most WASI implementation so far seem to just make a stdin and stdout available for a WASM program - which wouldn't really be enough to run a webserver in it.
Is this example running a non-wasm webserver that then proxies to WASM modules? Is that wasmedge? Or does wasmedge really make syscalls like accept() available to the module?
If it's the latter, how could it actually do something meaningful without threading - given any accept() would block the whole module? Run in non-blocking mode and expect the whole WASM module to be written in async style?
I know these are lots of questions - but they seem rather fundamental to what you could actually use the system for.
I think this is mostly a land grab to have docker image repositories be the distribution method of choice for wasi.
> If it's the latter, how could it actually do something meaningful without threading - given any accept() would block the whole module? Run in non-blocking mode and expect the whole WASM module to be written in async style?
The docs here show how it works: https://wasmedge.org/book/en/write_wasm/rust/networking.html
BTW, the two WASM runtimes jockeying for position are wasmtime and wasmer. It looks like Docker is getting behind wasmtime.
https://www.destroyallsoftware.com/talks/the-birth-and-death...
I'd hope that they'd be comparable in performance, especially when it comes to doing client-side web app things in languages other than JavaScript.
So compiling JS to wasm would probably be limited to the performance of interpreting JS on native
However, I see Docker (and thus, Kubernetes) is as technologies of the past (I don’t intend to start any flamewar, I really believe this by heart). Metal compute (Web 1.0) lead to VMs which then lead to Containers (Web 2.0 / Cloud) and now we are seeing what the next wave will look like thanks to WebAssembly.
Of course, there’s ton of profit that has been generated thanks to the added complexity of current technologies and abstractions.
We have now the opportunity to rethink what the future will look like. Long live Wasm
the tweet is from 2019
> “So will wasm replace Docker?” No, but imagine a future where Docker runs linux containers, windows containers and wasm containers side by side. Over time wasm might become the most popular container type. Docker will love them all equally, and run it all :)
However, I'm genuinely interested - why would this make Kubernetes obsolete? If Wasm rules the future, as you believe, why shouldn't it run in a pod?
What do you mean when you say "scaling on the level of a function"?
Do you mean any "plain old" function or a specific REST endpoint like AWS Lambda?
If you could just throw distributed computing resources at any function that is a bottleneck in your code, that would be alien tech.
Going from coarse-grained compute to fine-grained compute. The finer grain you have, the more "composability" and "flexibility" you get.
At some point you become so fine-grain that all you have are just lambdas floating in the cloud. And universal pointers to data floating in the cloud. Wire them up and everything scales automatically.
Back when I was working on this sort of stuff, there was an intermediate development between containers and wasm, that being of library OS like mirage OS, unikernels... Etc. I think wasm has probably better positioning compared to those unikernels.
[0]: https://survey.stackoverflow.co/2022/#most-popular-technolog...
Don’t get me wrong though, I have tons of admiration for Docker (in fact, Solomon Hykes is an investor in Wasmer) and the great ergonomics you introduced along the way to help developers and reach the current status quo. Without you guys probably we would have reached the cloud advancements much later in time. However, we paid those advances with an order of magnitude greater complexity in other layers (with the likes of cloud providers profiting from it).
But now I sincerely believe we need more powerful abstractions for the edge, serverless and Web 3.
In any case, I’m incredibly excited that you are researching more into WebAssembly. That’s great for the ecosystem and also will help to bring more devs onboard. Thanks for all the work!
Without wasm, the unit of containerization for them is operating system process. Each process spins up a jvm that runs your app/backend API.
With wasm, the unit of containerization is the exact functions of your backend API. So they can fit more "containers" on a single machine, compared to docker. And that brings faster startups etc..
It is to containers what containers were to VMs?
If so, they need diagrams making that argument same way we all saw for containers vs VMs.
The only risk is if splitting the effort damages them in both fields...
As far as Wasm itself, it's designed to provide a fast, lightweight, secure, and portable binary format. While it was originally designed to help bring native code to the browser, it's quickly spreading to the server side. Many folks are using it for edge/IoT, but it's growing into other areas (saw demos today of even using it in databases as psuedo stored procedures). Happy to dive in more if you have more questions!
But tbh if orchestration is really the concern, Docker + wasm seems less efficient than having a dedicated app that can orchestrate multiple wasm modules within the same process. But maybe that's something docker can solve later as the actual requirements emerge.
I'm a bit surprised by several comments in this post talking about how WASM could replace containers but I don't have the context around it
Summary of summary: Dockerfile -> docker build -> docker container with the WASM app and runtime inside -> docker push/pull -> docker run container.
However, even if I never compiled anything to WASM I think that it was already possible to build an image with a WASM container and runtime inside (as for any other language/runtime.) So what's the friction this is removing from the process?
What, exactly, is Docker doing? Is it compiling the application? Is it making a runtime for the wasm binary? Is it being the runtime for the wasm binary, so the end user builds through whatever usual build processes and gets a binary they can then easily run?
If the wasm binary is lightweight and portable, why is docker useful?
edit: Given the other comments about "what problem does this solve" I think maybe the blog post has missed its mark slightly
I wonder if it could make testing frontend code that uses WASM (but not DOM) fast and easy since you wouldn’t need to fire up a complete browser environment.
I’m not sure that it’s possible at the moment. In the past when I needed to test a WASM integration, I ended up using that approach and it was kind of a pain not to get immediate feedback on the WASM code’s API tests since it was essentially only testable through the complete integration environment.
I like integration tests, but I like smaller and faster test suites for easing development in some conditions as well.
You can currently test a WASM-targeted API if you use unit tests or other language-level testing approaches, but you won’t get the constraints of the WASM runtime as far as I know. Maybe the lack of garbage collection could be a critical constraint to test against.
I suppose you could even test dynamically linked binaries without a browser as well.
I’m sure there’s far more to it that I’m not aware of, and maybe testing really isn’t that useful of a feature here — I’m just guessing based on my own experience.
But... certainly a neat idea to think about what Wasm-based applications could possibly look like/run in the browser!
1. Visit https://postgresql.com/try?version=14.x
2. Visit https://nodejs.com/try?version=16.15.1
3. Visit https://edit.com
Edit.com opens a text-editor and terminal where I have access to the NodeJS binary and a connection string to PostgresQL. Want Redis? Open a new tab at https://redis.com/try, where the connection string will appear in the edit.com tab.I miss a feature where I can share a link with some data/schema pre-seeded (maybe from a gist?)
Snaplet.dev is a tool that copies, minimizes and transforms your production database into a shareable file.
Are there namespaces and cgroups and SECCOMP and blocking for concurrent hardware access in WASM, or would those kernel protections be effective within a WASM runtime? Do WASM runtimes have subprocess isolation?
- TIL about teh Endokernel: "The Endokernel: Fast, Secure, and Programmable Subprocess Virtualization" (2021) https://arxiv.org/abs/2108.03705#
> The Endokernel introduces a new virtual machine abstraction for representing subprocess authority, which is enforced by an efficient self-isolating monitor that maps the abstraction to system level objects (processes, threads, files, and signals). We show how the Endokernel can be used to develop specialized separation abstractions using an exokernel-like organization to provide virtual privilege rings, which we use to reorganize and secure NGINX. Our prototype, includes a new syscall monitor, the nexpoline, and explores the tradeoffs of implementing it with diverse mechanisms, including Intel Control Enhancement Technology. Overall, we believe sub-process isolation is a must and that the Endokernel exposes an essential set of abstractions for realizing this in a simple and feasible way.
- [x] Linux containers
- [ ] WASM with or without WASI
eWASM has costed opcodes; basically like dynamic tracing in CPython.
Are there side channels for many or most of these sandboxing methods; even at the CPU level?
> gVisor is an application kernel, written in Go, that implements a substantial portion of the Linux system surface. It includes an Open Container Initiative (OCI) runtime called runsc that provides an isolation boundary between the application and the host kernel.
A bigger peeve is that there is no general reasonably fast cross build ability, to eg build, test and debug ARM images (for runnign on ARM servers) on x86 Linux or Windows etc.
There's Rosetta emulation and qemu emulation.
Rosetta emulation is quite fast. But docker does not use it. At least for now.
qemu emulation is extraordinarily slow and basically unusable for anything but the simplest code.
Most images nowadays have ARM version, so probably that's how most people use it.
Although; do we need a compiler for Java? It may be going full circle.
> One benefit of using wasm is architecture-agnostic binary. Right now you can't run x86 binary on ARM or vice-versa.
That was the advantage given for the JVM. The .jar ran on x86 and ARM.
Running raw WASM is similar to running Java bytecode, but with fewer cross-platform APIs.
Yes, we need a compiler for Java. Java sources are compiled to Java bytecode along with many other actions for complex projects like downloading dependencies, generating sources, running tests which might run platform-dependent binaries and so on.
> That was the advantage given for the JVM. The .jar ran on x86 and ARM.
Yes, wasm and Java bytecode are the same in that regard. But Java bytecode failed to get adoption outside of Java world. Wasm might not, we will see. One significant improvement of Wasm over Java is good security story. Java sandbox is well known for its CVEs. Browser wasm implementations are battle-tested on billions of devices in the wild Internet. So you basically can't run untrusted Java bytecode without further boundaries like KVM or at least containers. But you definitely can run untrusted Wasm bytecode because that's what your browser does all the time.
Are there realistic benchmarks that quantify these gains?
A first view of the promise reads reminiscent to the JVM days, which promised to solve portability. The main difference is JIT vs. AOT, but hidden behind that remains also the complex management of FS access, threading, spawning, SIMD, GPU, and other unportable differences. While I imagine that the shim would avoid having a whole Linux, what do we lose in the change?
For serverless usecases, cloudflare etc.. found that it would be faster to just call a function from a wasm binary than spin up a whole docker container [1]. Which basically translated to cost savings.
In the last company I worked for [2], we saw wasm as a way to easily ship user code in a cross platform way. We mostly targeted edge-ml use cases. Wasm allowed us to package all the "libraries"/functions needed to run the user code securely. So users created and tested out their ML apps in browser and deployed them to all the platforms we supported. (Mobile, Browser, Embedded). As an added bonus they could write each of their functions in any language that compiled to wasm, and just ship it as one "app".
1. https://blog.cloudflare.com/cloud-computing-without-containe... 2. https://hotg.dev/
We have technology like WebVM [1] (from leaningtech / CheerP) or Copy86 [2] that already allows x86 machine code execution/emulation on the web. If you add an OCI client layer on top that is executable in the browser, it should be possible to run Docker containers in the browser.
I wouldn’t have considered running my Java or python on wasm because it’s all server side… that’s just what it does… but the single execution environment with sandboxing is very interesting.
I definitely need a wasm crash course
But on the other hand I'm not really happy with the fact that I'm waiting for GC and DOM access since 2019 or something like that
and it doesn't seem like we're getting close
There are a few limitations right now, some of which lack of built-in garbage collection and multi-threading. You also have to use a language that can completely compile to Wasm, making it hard (sometimes impossible) to leverage already built libraries/binaries.
But... the tech is growing rapidly and we're excited for it! Happy to dive in or answer more questions if you'd like!
A couple questions:
1. What use cases are you targeting, or which ones do you think have the most benefits from wasm?
2. What tools/stack are you currently using, or which ones do you think are the most promising?
And since it is a sandbox.. either you, or your friendly wasm interpreter (via. wasi etc...) needs to provide the system access APIs for various things like storage/filesystem access, hardware acceleration via. GPU, TPU etc.. And some of the standard APIs we take for granted.
And for places where you can't use JIT compilation (like iOS... - which is where most of the users/developers of our app were) there are interpreters like wasm3.
There was supposed to be a way to use the webassembly interpreter from JSCore but i am afraid my iOS knowledge doesn't go that far.
* The GC MVP spec is mostly done at this point.
* There are working toolchains for multiple languages: Java, Dart, Kotlin, and others have begun work as well.
* We will have a Phase 3 vote this week.
I read that press release or whatever a couple of times and I still can't figure out what the point is.
When I first saw it I was hoping that it would free Docker from the chains of VMs. (On Windows and Mac) If images target WASM then you should be able to run on them on any platform supporting WASM right?
I dont think that is what it does.
Seriously, if you're in a position to be running native code in your environment why would you chose WASM? If you're building WASM for the web, is it really more expensive to build a pure native target out of the same source? Surely, performance wise you'll always be ahead going native.
And I don’t understand why docker is supporting this as docker + wasm makes no sense at all as wasm wants to replace docker as the runtime provider …
Constraints give you freedom because they allow you to make guarantees. Checksums, reliable test suites, and good software abstractions are all examples.
> I don’t want to be forced to use go or rust - maybe I’d like to use bash, node or even the jvm depending on the problem I need to solve.
Those are runtimes, not languages. Here's a list of languages that compile to WASM: https://www.fermyon.com/wasm-languages/webassembly-language-...
IMO bash wouldn't make sense, but Java and Kotlin are there, as well as AssemblyScript, which is basically TypeScript.
Could be x86, arm, some native wasm hardware, who knows. As long as it's cheap.
Then we immediately trade any semblance of sanity for container orchestration.
(And please don't try to convince me that Kubernetes is sane. I operated a production SaaS on it for 4 years, and spent another year at a DevSecOps consultancy with 40+ CKAs—sanity and familiarity are not the same.)
I don't remember exactly when he says it's time to get rid of containers and VMs, but it's in there...
https://www.destroyallsoftware.com/talks/the-birth-and-death...
I know this wasn't your main point, but if I could reasonably tattoo this onto my forehead I would.
So, to your point, the opportunity here is to provide WASM-native alternatives to existing container-specific technologies, that are more composable by design, because they don't have to deal with the complexity of trying to ape an extra operating system just to run some software.
For example, I'd love to see container orchestration be supplanted by something like a la carte Erlang-style service discovery—that's a primitive that could easily be composed with other primitives, and wouldn't result in the combinatorial explosion of nouns we see in systems like k8s / Swarm / others.
Within that framework, we see Wasm as extremely compatible with our goals of improving the local development experience, and yes, giving people alternatives to container-centric approaches. I’m personally inclined to agree with the points you are making about opportunities in orchestration, but we’re starting today by just trying to give people to a solid toolset that lets you iterate on your Wasm apps locally, and easily export the resulting artifacts, so you can deploy them as you see fit. In the process we try to be careful about shedding any container-centric assumptions, while porting over some of the wins of the docker tooling that we think can translate well to Wasm (easy local dev environment, standard artifacts, broad platform compatibility across Windows/Linux/M1, etc.) We will happily work with anyone interested in working with us to improve the production/deployment landscape for Wasm, and in fact I would say the main reason that drove us to launch this technical preview today, was to attract feedback on how the Wasm community (ourselves included) could best deliver an alternative path to production for applications going forward.
Hope this makes sense and that I understood your point accurately!
I'm happy to hear all of that and, yes, I believe you did.
> Docker [...] is singularly focused on the development experience, i.e. the inner loop of code/test/build, not the outer loop of deploying to production (which is largely controlled by cloud platforms and k8s at this point).
I would push back on this a bit: although it may not be a focus, and that's totally fair, deployment is undeniably part of the developer experience, particularly within the context that containers were born into (i.e. DevOps values of continuous deployment & no silos). I certainly wouldn't presume to tell you what to do, but I would suggest that Docker is uniquely situated to address developer experience from end to end.
> We will happily work with anyone interested in working with us to improve the production/deployment landscape for Wasm
If you gave us a path out of containers for the end-to-end developer experience, I believe many of us would be eternally grateful. Let me know how I can help.
We don't. But shortsighted design, rushing, and herd mentality around "hyped" tech make it a virtual certainty more like this will exist, just in different shapes and sizes.
You can run most stuff on a baremetal box or VM w/ direct install of dependencies. All of this container stuff, sorry to say, is a grift save for some extreme multi-tenant use cases.