{"id":28406421,"url":"https://github.com/hwclass/docker-beta-wasm-example","last_synced_at":"2026-01-27T09:39:40.396Z","repository":{"id":259968529,"uuid":"879939996","full_name":"hwclass/docker-beta-wasm-example","owner":"hwclass","description":"🚀 A simple example demonstrating how to run WebAssembly modules in Docker (Beta)","archived":false,"fork":false,"pushed_at":"2024-10-28T21:06:56.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-29T08:38:07.230Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hwclass.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-28T20:25:46.000Z","updated_at":"2024-10-28T21:06:59.000Z","dependencies_parsed_at":"2024-10-28T21:42:39.207Z","dependency_job_id":null,"html_url":"https://github.com/hwclass/docker-beta-wasm-example","commit_stats":null,"previous_names":["hwclass/docker-beta-wasm-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hwclass/docker-beta-wasm-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hwclass%2Fdocker-beta-wasm-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hwclass%2Fdocker-beta-wasm-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hwclass%2Fdocker-beta-wasm-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hwclass%2Fdocker-beta-wasm-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hwclass","download_url":"https://codeload.github.com/hwclass/docker-beta-wasm-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hwclass%2Fdocker-beta-wasm-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28810958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T07:41:26.337Z","status":"ssl_error","status_checked_at":"2026-01-27T07:41:08.776Z","response_time":168,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-01T22:11:16.409Z","updated_at":"2026-01-27T09:39:40.390Z","avatar_url":"https://github.com/hwclass.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker (Beta) with WASM\n\n🚀 A simple example demonstrating how to run WebAssembly modules in Docker (Beta)\n\n## Prerequisites\n\n- Docker Desktop (Latest version)\n- Rust (for building the WASM module)\n- Git\n\n## Project Structure\n\n```\ndocker-wasm-example/\n├── src/\n│   └── main.rs\n├── Cargo.toml\n├── .dockerignore\n├── Dockerfile\n└── README.md\n```\n\n## Setup Instructions\n\n### 1. Enable WASM Support in Docker Desktop\n\n1. Open Docker Desktop\n2. Navigate to **Settings** (gear icon)\n3. In the **General** tab, ensure \"Use containerd for pulling and storing images\" is enabled\n\n![Screenshot 2024-10-28 at 21 35 38](https://github.com/user-attachments/assets/05422d62-936e-413f-8d7f-66c080c3f140)\n\n4. Go to **Features in development**\n5. Check \"Enable Wasm\"\n\n![Screenshot 2024-10-28 at 21 34 39](https://github.com/user-attachments/assets/0cd099d4-d621-44b1-82e8-38f50eb21247)\n\n6. Click **Apply \u0026 restart**\n7. In the confirmation dialog, click **Install** to install the WASM runtimes\n8. Wait for Docker Desktop to restart\n\n### 2. Create Project Files\n\nCreate a new Rust project:\n\n```sh\ncargo new docker-wasm-example\ncd docker-wasm-example\n```\n\nCreate `Cargo.toml`:\n\n```toml\n[package]\nname = \"wasm-example\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[dependencies]\nanyhow = \"1.0\"\n\n[lib]\ncrate-type = [\"cdylib\"]\n```\n\nCreate `src/main.rs`:\n\n```rust\nuse std::prelude::v1::*;\n\nfn main() -\u003e anyhow::Result\u003c()\u003e {\n    println!(\"Hello from WASM!\");\n    Ok(())\n}\n```\n\nCreate `.dockerignore`:\n\n```\ntarget/\nCargo.lock\n```\n\nCreate `Dockerfile`:\n\n```dockerfile\n# syntax=docker/dockerfile:1\nFROM --platform=$BUILDPLATFORM rust:1.70-slim as builder\n\nWORKDIR /app\n\n# Install required dependencies\nRUN apt-get update \u0026\u0026 apt-get install -y \\\n    cmake \\\n    \u0026\u0026 rm -rf /var/lib/apt/lists/*\n\n# Install WASI target\nRUN rustup target add wasm32-wasi\n\n# Copy project files\nCOPY . .\n\n# Build for WASI target\nRUN cargo build --target wasm32-wasi --release\n\nFROM scratch\nCOPY --from=builder /app/target/wasm32-wasi/release/wasm-example.wasm /app.wasm\nENTRYPOINT [ \"/app.wasm\" ]\n```\n\n### 3. Build and Run\n\n1. Create and use a new builder for WASM:\n\n```sh\ndocker buildx rm wasm-builder --force\ndocker buildx create --name wasm-builder --driver docker-container --bootstrap\ndocker buildx use wasm-builder\n```\n\n2. Build the WASM container:\n\n```sh\ndocker buildx build \\\n    --platform wasi/wasm32 \\\n    --build-arg BUILDPLATFORM=$(docker version -f '{{.Server.Os}}/{{.Server.Arch}}') \\\n    --load \\\n    -t wasm-example .\n```\n\n3. Run the container with different runtimes:\n\n**WasmEdge** (Recommended for general use)\n\n```sh\ndocker run --runtime=io.containerd.wasmedge.v1 --platform=wasi/wasm32 wasm-example\n```\n\n**Wasmer**\n\n```sh\ndocker run --runtime=io.containerd.wasmer.v1 --platform=wasi/wasm32 wasm-example\n```\n\n**Wasmtime**\n\n```sh\ndocker run --runtime=io.containerd.wasmtime.v1 --platform=wasi/wasm32 wasm-example\n```\n\n**Slight**\n\n```sh\ndocker run --runtime=io.containerd.slight.v1 --platform=wasi/wasm32 wasm-example\n```\n\n**Spin**\n\n```sh\ndocker run --runtime=io.containerd.spin.v2 --platform=wasi/wasm32 wasm-example\n```\n\n**Lunatic**\n\n```sh\ndocker run --runtime=io.containerd.lunatic.v1 --platform=wasi/wasm32 wasm-example\n```\n\n**WWS (Wasm Workers Server)**\n\n```sh\ndocker run --runtime=io.containerd.wws.v1 --platform=wasi/wasm32 wasm-example\n```\n\n### Runtime Comparison\n\n```\n| Runtime | Best For | Key Features |\n|---------|----------|--------------|\n| WasmEdge | General purpose | Good performance, broad compatibility |\n| Wasmer | Production | Strong ecosystem, good performance |\n| Wasmtime | Development | Fast startup, good debugging |\n| Slight | Lightweight apps | Minimal resource usage |\n| Spin | Web services | HTTP-focused features |\n| Lunatic | Distributed systems | Actor-based concurrency |\n| WWS | Worker systems | Background processing |\n```\n\n## Troubleshooting\n\n### Common Issues\n\n1. **Builder exists error**\n\n```sh\ndocker buildx rm wasm-builder --force\ndocker buildx create --name wasm-builder --driver docker-container --bootstrap\n```\n\n2. **Runtime not found**\n\n```sh\ndocker info | grep wasm\n```\n\n3. **Build fails**\n\n```sh\n# Clean Docker build cache\ndocker builder prune\n# Remove and recreate builder\ndocker buildx rm wasm-builder\ndocker buildx create --name wasm-builder --driver docker-container --bootstrap\n```\n\n4. **WASI dependencies error**\n\n```sh\nrustup target add wasm32-wasi --force\ncargo clean\n```\n\n## Contributing\n\nFeel free to submit issues and enhancement requests!\n\n## License\n\nMIT\n\n---\n\n🔧 Built with ❤️ using Docker WASM support\n\nKey changes:\n\n1. Updated Cargo.toml with proper dependencies and crate type\n2. Added proper error handling in main.rs\n3. Simplified Dockerfile build process\n4. Added comprehensive runtime comparison table\n5. Added examples for all available runtimes\n6. Updated troubleshooting section with WASI-specific issues\n\nCitations: [1]\nhttps://ppl-ai-file-upload.s3.amazonaws.com/web/direct-files/7954569/b3c29962-c5b2-4755-b9a7-f6ac868bd5a7/paste.txt\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhwclass%2Fdocker-beta-wasm-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhwclass%2Fdocker-beta-wasm-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhwclass%2Fdocker-beta-wasm-example/lists"}