Code Monkey home page Code Monkey logo

container2wasm's People

Contributors

dependabot[bot] avatar kateinoigakukun avatar ktock avatar steren avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

container2wasm's Issues

Run failed on Ubuntu 22.04, arch amd64

Finding your help on the error while I'm trying to play around with c2w. I'm converting my simple Python container.

I'm using lima to run my VM:

 uname -a
Linux lima-ubuntu 5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

My docker file to build Python image, this is a simple script print Hello world:

FROM python:3

WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY test.py .

COPY . .

CMD ["python", "test.py"]

I run ./c2w --target-arch=amd64 test-py /tmp/out/python.wasm and there's log:

#63 54.56 genisoimage: Error: /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-1.a and /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-2.a have the same Joliet name
#63 54.57 genisoimage: Error: /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-0.a and /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-1.a have the same Joliet name
#63 54.58 genisoimage: Error: /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-2.a and /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-0.a have the same Joliet name
#63 54.58 genisoimage: Error: /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-1.a and /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-0.a have the same Joliet name
#63 54.58 genisoimage: Error: /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-1.a and /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-2.a have the same Joliet name
#63 54.60 Joliet tree sort failed. The -joliet-long switch may help you.
#63 ERROR: process "/bin/sh -c mkdir /out/ && mkisofs -l -J -r -o /out/rootfs.bin /rootfs/" did not complete successfully: exit code: 1

#25 [tinyemu-dev-common  6/11] RUN git clone https://github.com/kateinoigakukun/wasi-vfs.git --recurse-submodules &&     cd wasi-vfs &&     git checkout "ddbea0e2a6a1e0e8fe0373ec3d1bdccf522178ab" &&     cargo build --target wasm32-unknown-unknown &&     cargo build --package wasi-vfs-cli &&     mkdir -p /tools/wasi-vfs/ &&     mv target/debug/wasi-vfs target/wasm32-unknown-unknown/debug/libwasi_vfs.a /tools/wasi-vfs/ &&     cargo clean
#25 CANCELED
------
 > [rootfs-dev 12/12] RUN mkdir /out/ && mkisofs -l -J -r -o /out/rootfs.bin /rootfs/:
#63 53.28 Using SYS000;1 for  /rootfs/oci/rootfs/usr/lib/x86_64-linux-gnu/perl/5.32.1/Sys (sys)
#63 54.55 genisoimage: Error: /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-1.a and /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-0.a have the same Joliet name
#63 54.56 genisoimage: Error: /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-obsolete-l1-1-1.a and /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-processtopology-obsolete-l1-1-0.a have the same Joliet name
#63 54.56 genisoimage: Error: /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-0.a and /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-2.a have the same Joliet name
#63 54.56 genisoimage: Error: /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-1.a and /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecoreuap-api-ms-win-core-windowserrorreporting-l1-1-2.a have the same Joliet name
#63 54.57 genisoimage: Error: /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-0.a and /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_onecore-api-ms-win-core-processtopology-obsolete-l1-1-1.a have the same Joliet name
#63 54.58 genisoimage: Error: /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-2.a and /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-0.a have the same Joliet name
#63 54.58 genisoimage: Error: /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-1.a and /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-0.a have the same Joliet name
#63 54.58 genisoimage: Error: /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-1.a and /rootfs/oci/rootfs/app/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0/lib/libwinapi_windowsapp-api-ms-win-core-windowserrorreporting-l1-1-2.a have the same Joliet name
#63 54.60 Joliet tree sort failed. The -joliet-long switch may help you.
------
Dockerfile:185
--------------------
 183 |     RUN mkdir -p /rootfs/proc /rootfs/sys /rootfs/mnt /rootfs/run /rootfs/tmp /rootfs/dev /rootfs/var && mknod /rootfs/dev/null c 1 3 && chmod 666 /rootfs/dev/null
 184 |     RUN touch /rootfs/etc/resolv.conf /rootfs/etc/hosts
 185 | >>> RUN mkdir /out/ && mkisofs -l -J -r -o /out/rootfs.bin /rootfs/
 186 |     # RUN isoinfo -i /out/rootfs.bin -l
 187 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c mkdir /out/ && mkisofs -l -J -r -o /out/rootfs.bin /rootfs/" did not complete successfully: exit code: 1
exit status 1

Thank you for your time of reading.

Failed to run frr with wasmtime: Can't create pid lock file /var/run/frr/watchfrr.pid (No such file or directory), exiting

I am trying to run FRRouting (a BGP routing software in C) in wasmtime, I have successfully converted the Docker image: https://hub.docker.com/r/frrouting/frr to .wasm file.

image

But when running with wasmtime, it gets error:

F:\container2wasm\cmd\c2w>wasmtime frr.wasm 2023/09/14 02:47:51 WATCHFRR: [XNZM2-2XF6G][EC 100663303] Can't create pid lock file /var/run/frr/watchfrr.pid (No such file or directory), exiting

My env:

Update:

I also tested on WSL (Ubuntu) with wasmtime and the result is the same (I just reused the same frr.wasm, which is built by container2wasm on Windows):

image

image

How to resolve it? Thanks!

Impossible to run with mac M1

I'm trying to run c2w on Mac M1. Here are the errors I get:

c2w ubuntu:22.04 out.wasm

This gives me this error:

...
#39 2.127 HEAD is now at 89bec45 bump: version 0.3.0
#39 2.150 info: syncing channel updates for '1.61.0-aarch64-unknown-linux-gnu'
#39 CANCELED
------
 > [runc-amd64-dev 2/2] RUN --mount=type=cache,target=/root/.cache/go-build     --mount=type=cache,target=/go/pkg/mod     git clone https://github.com/opencontainers/runc.git /go/src/github.com/opencontainers/runc &&     cd /go/src/github.com/opencontainers/runc &&     git checkout "v1.1.9" &&     make static GOARCH=amd64 CC=gcc EXTRA_LDFLAGS='-s -w' BUILDTAGS="" EXTRA_LDFLAGS='-s -w' BUILDTAGS="" &&     mkdir -p /out/ && mv runc /out/runc:
3.151 
3.151   git switch -
3.151 
3.151 Turn off this advice by setting config variable advice.detachedHead to false
3.151 
3.151 HEAD is now at ccaecfcb VERSION: release 1.1.9
3.225 go build -trimpath -buildmode=pie  -tags " netgo osusergo" -ldflags "-X main.gitCommit=v1.1.9-0-gccaecfcb -X main.version=1.1.9 -linkmode external -extldflags --static-pie -s -w" -o runc .
3.470 # runtime/cgo
3.470 gcc: error: unrecognized command-line option '-m64'
3.508 make: *** [Makefile:69: static] Error 1
------
Dockerfile:332
--------------------
 331 |     RUN apt-get update -y && apt-get install -y git make gperf
 332 | >>> RUN --mount=type=cache,target=/root/.cache/go-build \
 333 | >>>     --mount=type=cache,target=/go/pkg/mod \
 334 | >>>     git clone https://github.com/opencontainers/runc.git /go/src/github.com/opencontainers/runc && \
 335 | >>>     cd /go/src/github.com/opencontainers/runc && \
 336 | >>>     git checkout "${RUNC_VERSION}" && \
 337 | >>>     make static GOARCH=amd64 CC=gcc EXTRA_LDFLAGS='-s -w' BUILDTAGS="" EXTRA_LDFLAGS='-s -w' BUILDTAGS="" && \
 338 | >>>     mkdir -p /out/ && mv runc /out/runc
 339 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c git clone https://github.com/opencontainers/runc.git /go/src/github.com/opencontainers/runc &&     cd /go/src/github.com/opencontainers/runc &&     git checkout \"${RUNC_VERSION}\" &&     make static GOARCH=amd64 CC=gcc EXTRA_LDFLAGS='-s -w' BUILDTAGS=\"\" EXTRA_LDFLAGS='-s -w' BUILDTAGS=\"\" &&     mkdir -p /out/ && mv runc /out/runc" did not complete successfully: exit code: 2
exit status 1

And with a target arm :

c2w --target-arch=arm ubuntu:22.04 out.wasm

This gives me this error:

...
#23 12.37 info: downloading component 'rust-std' for 'wasm32-unknown-unknown'
#23 16.47 info: downloading component 'rust-std' for 'wasm32-wasi'
#23 CANCELED
------
 > [gcc-riscv64-linux-gnu-base 2/2] RUN apt-get update && apt-get install -y gcc-riscv64-linux-gnu libc-dev-riscv64-cross git make:
7.705 Fetched 22.4 MB in 7s (3171 kB/s)
7.705 Reading package lists...
12.05 Reading package lists...
16.13 Building dependency tree...
16.66 Reading state information...
16.67 Package gcc-riscv64-linux-gnu is not available, but is referred to by another package.
16.67 This may mean that the package is missing, has been obsoleted, or
16.67 is only available from another source
16.67 
16.67 E: Package 'gcc-riscv64-linux-gnu' has no installation candidate
------
Dockerfile:71
--------------------
  69 |     
  70 |     FROM ubuntu:22.04 AS gcc-riscv64-linux-gnu-base
  71 | >>> RUN apt-get update && apt-get install -y gcc-riscv64-linux-gnu libc-dev-riscv64-cross git make
  72 |     
  73 |     FROM gcc-riscv64-linux-gnu-base AS bbl-dev
--------------------
ERROR: failed to solve: process "/bin/sh -c apt-get update && apt-get install -y gcc-riscv64-linux-gnu libc-dev-riscv64-cross git make" did not complete successfully: exit code: 100
exit status 1

This doesn't work with other containers (like Python, for example).

If you have any idea how to solve this problem, I'd love to hear from you. I'm trying to find a solution myself, and if I do, I'll update this page.

Many thanks :)

Fail to transform locally built image: `panic: unsupported mediatype application/vnd.oci.image.index.v1+json`

I have no issue transforming images from DockerHub like alpine

But an image I built locally with the following Dockerfile

FROM alpine:3.14
RUN apk add inkscape
ENTRYPOINT ["inkscape"]

errors:

#21 [bundle-dev 5/7] RUN mkdir -p /out/oci/rootfs /out/oci/bundle &&     IS_WIZER=false &&     if test "wizer" = "wizer" ; then IS_WIZER=true ; fi &&     NO_VMTOUCH_F=false &&     if test "wizer" = "native" ; then NO_VMTOUCH_F=true ; fi &&     if test "" != "" ; then NO_VMTOUCH_F="" ; fi &&     EXTERNAL_BUNDLE_F=false &&     if test "" = "true" ; then EXTERNAL_BUNDLE_F=true ; fi &&     create-spec --debug=false --debug-init=${IS_WIZER} --no-vmtouch=${NO_VMTOUCH_F} --external-bundle=${EXTERNAL_BUNDLE_F}                 --image-config-path=/oci/image.json                 --runtime-config-path=/oci/spec.json                 --rootfs-path=/oci/rootfs                 /oci "linux/amd64" /out/oci/rootfs
#21 0.356 Trying to unpack image as an OCI image
#21 0.359 panic: unsupported mediatype application/vnd.oci.image.index.v1+json
#21 0.359
#21 0.359 goroutine 1 [running]:
#21 0.359 main.main()
#21 0.359       /work/cmd/create-spec/main.go:57 +0x5ac
#21 ERROR: process "/bin/sh -c mkdir -p /out/oci/rootfs /out/oci/bundle &&     IS_WIZER=false &&     if test \"${OPTIMIZATION_MODE}\" = \"wizer\" ; then IS_WIZER=true ; fi &&     NO_VMTOUCH_F=false &&     if test \"${OPTIMIZATION_MODE}\" = \"native\" ; then NO_VMTOUCH_F=true ; fi &&     if test \"${NO_VMTOUCH}\" != \"\" ; then NO_VMTOUCH_F=\"${NO_VMTOUCH}\" ; fi &&     EXTERNAL_BUNDLE_F=false &&     if test \"${EXTERNAL_BUNDLE}\" = \"true\" ; then EXTERNAL_BUNDLE_F=true ; fi &&     create-spec --debug=${INIT_DEBUG} --debug-init=${IS_WIZER} --no-vmtouch=${NO_VMTOUCH_F} --external-bundle=${EXTERNAL_BUNDLE_F}                 --image-config-path=/oci/image.json                 --runtime-config-path=/oci/spec.json                 --rootfs-path=/oci/rootfs                 /oci \"${TARGETPLATFORM}\" /out/oci/rootfs" did not complete successfully: exit code: 2
------
 > [bundle-dev 5/7] RUN mkdir -p /out/oci/rootfs /out/oci/bundle &&     IS_WIZER=false &&     if test "wizer" = "wizer" ; then IS_WIZER=true ; fi &&     NO_VMTOUCH_F=false &&     if test "wizer" = "native" ; then NO_VMTOUCH_F=true ; fi &&     if test "" != "" ; then NO_VMTOUCH_F="" ; fi &&     EXTERNAL_BUNDLE_F=false &&     if test "" = "true" ; then EXTERNAL_BUNDLE_F=true ; fi &&     create-spec --debug=false --debug-init=${IS_WIZER} --no-vmtouch=${NO_VMTOUCH_F} --external-bundle=${EXTERNAL_BUNDLE_F}                 --image-config-path=/oci/image.json                 --runtime-config-path=/oci/spec.json                 --rootfs-path=/oci/rootfs                 /oci "linux/amd64" /out/oci/rootfs:
0.356 Trying to unpack image as an OCI image
0.359 panic: unsupported mediatype application/vnd.oci.image.index.v1+json
0.359
0.359 goroutine 1 [running]:
0.359 main.main()
0.359   /work/cmd/create-spec/main.go:57 +0x5ac
------
container2wasm3268470491:59
--------------------
  58 |     # <vm-rootfs>/oci/initconfig.json : configuration file for init
  59 | >>> RUN mkdir -p /out/oci/rootfs /out/oci/bundle && \
  60 | >>>     IS_WIZER=false && \
  61 | >>>     if test "${OPTIMIZATION_MODE}" = "wizer" ; then IS_WIZER=true ; fi && \
  62 | >>>     NO_VMTOUCH_F=false && \
  63 | >>>     if test "${OPTIMIZATION_MODE}" = "native" ; then NO_VMTOUCH_F=true ; fi && \
  64 | >>>     if test "${NO_VMTOUCH}" != "" ; then NO_VMTOUCH_F="${NO_VMTOUCH}" ; fi && \
  65 | >>>     EXTERNAL_BUNDLE_F=false && \
  66 | >>>     if test "${EXTERNAL_BUNDLE}" = "true" ; then EXTERNAL_BUNDLE_F=true ; fi && \
  67 | >>>     create-spec --debug=${INIT_DEBUG} --debug-init=${IS_WIZER} --no-vmtouch=${NO_VMTOUCH_F} --external-bundle=${EXTERNAL_BUNDLE_F} \
  68 | >>>                 --image-config-path=/oci/image.json \
  69 | >>>                 --runtime-config-path=/oci/spec.json \
  70 | >>>                 --rootfs-path=/oci/rootfs \
  71 | >>>                 /oci "${TARGETPLATFORM}" /out/oci/rootfs
  72 |     RUN if test -f image.json; then mv image.json /out/oci/ ; fi && \
--------------------
ERROR: failed to solve: process "/bin/sh -c mkdir -p /out/oci/rootfs /out/oci/bundle &&     IS_WIZER=false &&     if test \"${OPTIMIZATION_MODE}\" = \"wizer\" ; then IS_WIZER=true ; fi &&     NO_VMTOUCH_F=false &&     if test \"${OPTIMIZATION_MODE}\" = \"native\" ; then NO_VMTOUCH_F=true ; fi &&     if test \"${NO_VMTOUCH}\" != \"\" ; then NO_VMTOUCH_F=\"${NO_VMTOUCH}\" ; fi &&     EXTERNAL_BUNDLE_F=false &&     if test \"${EXTERNAL_BUNDLE}\" = \"true\" ; then EXTERNAL_BUNDLE_F=true ; fi &&     create-spec --debug=${INIT_DEBUG} --debug-init=${IS_WIZER} --no-vmtouch=${NO_VMTOUCH_F} --external-bundle=${EXTERNAL_BUNDLE_F}                 --image-config-path=/oci/image.json                 --runtime-config-path=/oci/spec.json                 --rootfs-path=/oci/rootfs                 /oci \"${TARGETPLATFORM}\" /out/oci/rootfs" did not complete successfully: exit code: 2
exit status 1

genisoimage: Error / mkisofs / Joliet tree sort failed. `-joliet-long` switch may help you.

Hi, thank you for this great product.

Basically, I try to make dotnet wasm.

Dockerfile

FROM archlinux:latest

RUN pacman -Syu --noconfirm && \
    pacman -S --noconfirm zsh nodejs npm git wget && \
    wget https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.sh && \
    sh ./dotnet-install.sh -v 8.0.201 && \
    export DOTNET_ROOT=$HOME/.dotnet && \
    export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools

sudo c2w foo arch-zsh-node-dotnet8.wasm

then, here is a build error:

3.091 genisoimage: Error: /rootfs/oci/rootfs/root/.dotnet/sdk/8.0.201/Sdks/Microsoft.NET.Sdk.BlazorWebAssembly/targets/Microsoft.NET.Sdk.BlazorWebAssembly.ServiceWorkerAssetsManifest.5_0.targets and /rootfs/oci/rootfs/root/.dotnet/sdk/8.0.201/Sdks/Microsoft.NET.Sdk.BlazorWebAssembly/targets/Microsoft.NET.Sdk.BlazorWebAssembly.ServiceWorkerAssetsManifest.targets have the same Joliet name
3.091 Joliet tree sort failed. The -joliet-long switch may help you.
------
container2wasm3626668171:402
--------------------
 400 |     COPY --link --from=tini-amd64-dev /out/tini /rootfs/sbin/tini
 401 |     RUN mkdir -p /rootfs/proc /rootfs/sys /rootfs/mnt /rootfs/run /rootfs/tmp /rootfs/dev /rootfs/var /rootfs/etc && mknod /rootfs/dev/null c 1 3 && chmod 666 /rootfs/dev/null
 402 | >>> RUN mkdir /out/ && mkisofs -l -J -R -o /out/rootfs.bin /rootfs/
 403 |     # RUN isoinfo -i /out/rootfs.bin -l
 404 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c mkdir /out/ && mkisofs -l -J -R -o /out/rootfs.bin /rootfs/" did not complete successfully: exit code: 1
exit status 1

As the error says:

/rootfs/oci/rootfs/root/.dotnet/sdk/8.0.201/Sdks/Microsoft.NET.Sdk.BlazorWebAssembly/targets/Microsoft.NET.Sdk.BlazorWebAssembly.ServiceWorkerAssetsManifest.5_0.targets

and

/rootfs/oci/rootfs/root/.dotnet/sdk/8.0.201/Sdks/Microsoft.NET.Sdk.BlazorWebAssembly/targets/Microsoft.NET.Sdk.BlazorWebAssembly.ServiceWorkerAssetsManifest.targets

have the same Joliet name, and Joliet tree sort failed.

The -joliet-long switch of mkisofs / genisoimage may help.


Before I use my own Dockerfile, I've tried the official dotnet container images:

https://github.com/devcontainers/images/tree/main/src/dotnet

and hit the same error, therefore this error seems inevitable.

Is there any possible work-around?

Thank you.

Failed to solve process "apt-get" for golang-base container

It seems that the golang-base has some problems when converting.

38.67 Reading package lists...
38.69 Building dependency tree...
38.70 Reading state information...
38.70 E: Unable to locate package gperf
------
container2wasm2433911993:337
--------------------
 335 |     FROM golang-base AS runc-amd64-dev
 336 |     ARG RUNC_VERSION
 337 | >>> RUN apt-get update -y && apt-get install -y git make gperf
 338 |     RUN --mount=type=cache,target=/root/.cache/go-build \
 339 |         --mount=type=cache,target=/go/pkg/mod \
--------------------
ERROR: failed to solve: process "/bin/sh -c apt-get update -y && apt-get install -y git make gperf" did not complete successfully: exit code: 100
exit status 1

Accelerate docker wasm workloads

Hi, that's a really awesome project you have created!
I've been thinking a lot lately on the in-browser virtualization topics, with my dream to run a full-blown linux distro with acceptable performance in the browser.
Something that comes to mind right now, related to container2wasm, docker now has (beta) support for wasm workloads - https://docs.docker.com/desktop/wasm/
I can't help but thinking there must be a way to run those in the browser with very good performance. I don't have any proper suggestion, just wanted to start a discussion. Could there be a way to forward the wasm workload execution straight to the browser? i.e. something like QEMU/Bochs/TinyEMU exposing a virtual WASM cpu (I realize that's really far-fetched and ambitious idea), so that wasm code can be executed by the virtualizing browser, instead of translated a number of times, and executed by the emulator.

Example Not Running

Hi,

I tried the wasi-browser example:

$ c2w ubuntu:22.04 out.wasm

The error I got:

#81 [bochs-dev-common  6/22] RUN git clone https://github.com/kateinoigakukun/wasi-vfs.git --recurse-submodules &&     cd wasi-vfs &&     git checkout "v0.3.0" &&     cargo build --target wasm32-unknown-unknown &&     cargo build --package wasi-vfs-cli &&     mkdir -p /tools/wasi-vfs/ &&     mv target/debug/wasi-vfs target/wasm32-unknown-unknown/debug/libwasi_vfs.a /tools/wasi-vfs/ &&     cargo clean
#0 1.495 Cloning into 'wasi-vfs'...
#0 2.012 Submodule 'crates/wasi-libc-trampoline-bindgen/WASI' (https://github.com/WebAssembly/WASI.git) registered for path 'crates/wasi-libc-trampoline-bindgen/WASI'
#0 2.015 Cloning into '/work/wasi-vfs/crates/wasi-libc-trampoline-bindgen/WASI'...
#81 CANCELED
------
 > [rootfs-amd64-dev 10/12] RUN mkdir -p /rootfs/proc /rootfs/sys /rootfs/mnt /rootfs/run /rootfs/tmp /rootfs/dev /rootfs/var /rootfs/etc && mknod /rootfs/dev/null c 1 3 && chmod 666 /rootfs/dev/null:
#78 0.965 mknod: /rootfs/dev/null: Operation not permitted
------
Dockerfile:409
--------------------
 407 |     COPY --link --from=vmtouch-amd64-dev /out/vmtouch /rootfs/bin/
 408 |     COPY --link --from=tini-amd64-dev /out/tini /rootfs/sbin/tini
 409 | >>> RUN mkdir -p /rootfs/proc /rootfs/sys /rootfs/mnt /rootfs/run /rootfs/tmp /rootfs/dev /rootfs/var /rootfs/etc && mknod /rootfs/dev/null c 1 3 && chmod 666 /rootfs/dev/null
 410 |     RUN touch /rootfs/etc/resolv.conf /rootfs/etc/hosts
 411 |     RUN mkdir /out/ && mkisofs -l -J -r -o /out/rootfs.bin /rootfs/
--------------------
ERROR: failed to solve: process "/bin/sh -c mkdir -p /rootfs/proc /rootfs/sys /rootfs/mnt /rootfs/run /rootfs/tmp /rootfs/dev /rootfs/var /rootfs/etc && mknod /rootfs/dev/null c 1 3 && chmod 666 /rootfs/dev/null" did not complete successfully: exit code: 1
exit status 1

sudo: The "no new privileges" flag is set, which prevents sudo from running as root.

I encountered this error when I was trying to create a privilege escalation challenge using container2wasm.

ctf@localhost:~$ sudo -l
sudo: The "no new privileges" flag is set, which prevents sudo from running as root.
sudo: If sudo is running in a container, you may need to adjust the container configuration to disable the flag.

I'm curious if this 'no new privileges' can be turned off, or if it provides any security benefits

Save State [Question]

Very interested in this project but wondering if there's anything similar to v86's emulator.save_state functionality: ex so there can be some level of persistence?

Networking error when running new demos

I've tried latest demos behind my own proxy and outside of it and either way apk on alpine or debian images gives me this
unable to connected to local proxy errors just using as-is .. should these demos work with apt-get etc as they advise to try?
Thanks looks cool and excited to learn more.

Wasi-Browser: Access exposed ports [Question]

Thanks again for this great project!
I'm trying to convert a web server container into wasm then run it in browser with wasi-browser. The container is exposing an http port, but unfortunately I am not able access it.

I've tried to add ˋEXPOSEˋ rule in Dockerfile, and to use port socket binding and port mapping in c2w-net to host port. Looking for GVisor networking, logs tell that connection is refused.

Do you have any idea or configuration to access exposed port, from c2w-net port mapping or directly from JS?

Thanks!

How to set browser VM specs (cpu mhz / available memory)?

Hi, I am using an alpine image to test nodejs performance with this project.

However when running cat /proc/cpuinfo, i get cpu MHz: 14.178 and cat /proc/meminfo gives a total memory of around 128MB.

Is this "normal"? What if I want to allocate let say 4GB of ram allowed by wasm32? What about the CPU, something seems odd with this low mhz, no?
In other words, any way to configure the "specs" of the VM in the browser?

Additionally, do containers have multi-threading support since wasm-thread are a thing and available with emscripten?

Cannot run even example from the documentation

Hello!

I may be doing something horribly wrong, but I do not see where I may be wrong as I am just follows the documentation:
I am running the following command:

c2w ubuntu:22.04 out.wasm

and get the following error quite far in the process.

#68 [bochs-dev-common  8/25] RUN git clone https://github.com/bytecodealliance/wizer &&     cd wizer &&     git checkout "04e49c989542f2bf3a112d60fbf88a62cce2d0d0" &&     cargo build --bin wizer --all-features &&     mkdir -p /tools/wizer/ &&     mv include target/debug/wizer /tools/wizer/ &&     cargo clean
...
#68 23.86    Compiling fs-set-times v0.15.0
#68 24.38    Compiling is-terminal v0.1.0
#68 24.40    Compiling wat v1.0.40
#68 24.59 error[E0061]: this method takes 1 argument but 2 arguments were supplied
#68 24.59   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/cap-primitives-0.24.1/src/rustix/linux/fs/set_times_impl.rs:20:25
#68 24.59    |
#68 24.59 20 |             return file.set_times(
#68 24.59    |                         ^^^^^^^^^
#68 24.59 21 |                 atime.map(SystemTimeSpec::into_std),
#68 24.59 22 |                 mtime.map(SystemTimeSpec::into_std),
#68 24.59    |                 ----------------------------------- unexpected argument of type `Option<fs_set_times::SystemTimeSpec>`
#68 24.59    |
#68 24.59 note: expected `FileTimes`, found `Option<SystemTimeSpec>`
#68 24.59   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/cap-primitives-0.24.1/src/rustix/linux/fs/set_times_impl.rs:21:17
#68 24.59    |
#68 24.59 21 |                 atime.map(SystemTimeSpec::into_std),
#68 24.59    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#68 24.59    = note: expected struct `FileTimes`
#68 24.59                 found enum `Option<fs_set_times::SystemTimeSpec>`
#68 24.59 note: method defined here
#68 24.59   --> /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/fs.rs:695:12
#68 24.59 help: remove the extra argument
#68 24.59    |
#68 24.59 21 -                 atime.map(SystemTimeSpec::into_std),
#68 24.59 21 +                 /* FileTimes */,
#68 24.59    |
#68 24.59 
#68 24.59 error[E0061]: this method takes 1 argument but 2 arguments were supplied
#68 24.59   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/cap-primitives-0.24.1/src/rustix/linux/fs/set_times_impl.rs:34:25
#68 24.59    |
#68 24.59 34 |             return file.set_times(
#68 24.59    |                         ^^^^^^^^^
#68 24.59 35 |                 atime.map(SystemTimeSpec::into_std),
#68 24.59 36 |                 mtime.map(SystemTimeSpec::into_std),
#68 24.59    |                 ----------------------------------- unexpected argument of type `Option<fs_set_times::SystemTimeSpec>`
#68 24.59    |
#68 24.59 note: expected `FileTimes`, found `Option<SystemTimeSpec>`
#68 24.59   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/cap-primitives-0.24.1/src/rustix/linux/fs/set_times_impl.rs:35:17
#68 24.59    |
#68 24.59 35 |                 atime.map(SystemTimeSpec::into_std),
#68 24.59    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#68 24.59    = note: expected struct `FileTimes`
#68 24.60                 found enum `Option<fs_set_times::SystemTimeSpec>`
#68 24.60 note: method defined here
#68 24.60   --> /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/fs.rs:695:12
#68 24.60 help: remove the extra argument
#68 24.60    |
#68 24.60 35 -                 atime.map(SystemTimeSpec::into_std),
#68 24.60 35 +                 /* FileTimes */,
#68 24.60    |
#68 24.60 
#68 24.66 For more information about this error, try `rustc --explain E0061`.
#68 24.67 error: could not compile `cap-primitives` (lib) due to 2 previous errors
#68 24.67 warning: build failed, waiting for other jobs to finish...

I run it on Ubuntu 22.04 machine (x64) with c2w v0.5.2.

I understand that it cannot build Wizer inside a docker environment. I can also see that a function is expected 2 arguments, but get one. I suspect that it is because of some kind of version mismatch somewhere, but where and what to do with it, I am not sure.

Can you, please, help me here.

Thanks.

cannot convert: `panic: archive/tar: invalid tar header`

Using c2w version v0.6.1 on WSL Ubuntu with latest Docker desktop:

As I try to convert an image I have built locally:

FROM alpine:3.14
RUN apk add inkscape
ENTRYPOINT ["inkscape"]

I now get this error

#29 [bundle-dev 5/7] RUN mkdir -p /out/oci/rootfs /out/oci/bundle &&     IS_WIZER=false &&     if test "wizer" = "wizer" ; then IS_WIZER=true ; fi &&     NO_VMTOUCH_F=false &&     if test "wizer" = "native" ; then NO_VMTOUCH_F=true ; fi &&     if test "" != "" ; then NO_VMTOUCH_F="" ; fi &&     EXTERNAL_BUNDLE_F=false &&     if test "" = "true" ; then EXTERNAL_BUNDLE_F=true ; fi &&     create-spec --debug=false --debug-init=${IS_WIZER} --no-vmtouch=${NO_VMTOUCH_F} --external-bundle=${EXTERNAL_BUNDLE_F}                 --image-config-path=/oci/image.json                 --runtime-config-path=/oci/spec.json                 --rootfs-path=/oci/rootfs                 /oci "linux/amd64" /out/oci/rootfs
#29 0.316 Trying to unpack image as an OCI image
#29 0.316 nested manifest: processing [{application/vnd.oci.image.manifest.v1+json sha256:afb32e6e1d58ffc85e2c2310dd22cee8a1b9b0db50b405e3db900c232bc1e2ac 566 [] map[vnd.docker.reference.digest:sha256:1621dc67fa1ef10281df47eef725170c6d7caf103cae442f1084e8344c3f3325 vnd.docker.reference.type:attestation-manifest] [] 0xc00006e3c0 }]
#29 0.318 panic: archive/tar: invalid tar header
#29 0.318
#29 0.318 goroutine 1 [running]:
#29 0.318 main.main()
#29 0.318       /work/cmd/create-spec/main.go:58 +0x5ac
#29 ERROR: process "/bin/sh -c mkdir -p /out/oci/rootfs /out/oci/bundle &&     IS_WIZER=false &&     if test \"${OPTIMIZATION_MODE}\" = \"wizer\" ; then IS_WIZER=true ; fi &&     NO_VMTOUCH_F=false &&     if test \"${OPTIMIZATION_MODE}\" = \"native\" ; then NO_VMTOUCH_F=true ; fi &&     if test \"${NO_VMTOUCH}\" != \"\" ; then NO_VMTOUCH_F=\"${NO_VMTOUCH}\" ; fi &&     EXTERNAL_BUNDLE_F=false &&     if test \"${EXTERNAL_BUNDLE}\" = \"true\" ; then EXTERNAL_BUNDLE_F=true ; fi &&     create-spec --debug=${INIT_DEBUG} --debug-init=${IS_WIZER} --no-vmtouch=${NO_VMTOUCH_F} --external-bundle=${EXTERNAL_BUNDLE_F}                 --image-config-path=/oci/image.json                 --runtime-config-path=/oci/spec.json                 --rootfs-path=/oci/rootfs                 /oci \"${TARGETPLATFORM}\" /out/oci/rootfs" did not complete successfully: exit code: 2
------
 > [bundle-dev 5/7] RUN mkdir -p /out/oci/rootfs /out/oci/bundle &&     IS_WIZER=false &&     if test "wizer" = "wizer" ; then IS_WIZER=true ; fi &&     NO_VMTOUCH_F=false &&     if test "wizer" = "native" ; then NO_VMTOUCH_F=true ; fi &&     if test "" != "" ; then NO_VMTOUCH_F="" ; fi &&     EXTERNAL_BUNDLE_F=false &&     if test "" = "true" ; then EXTERNAL_BUNDLE_F=true ; fi &&     create-spec --debug=false --debug-init=${IS_WIZER} --no-vmtouch=${NO_VMTOUCH_F} --external-bundle=${EXTERNAL_BUNDLE_F}                 --image-config-path=/oci/image.json                 --runtime-config-path=/oci/spec.json                 --rootfs-path=/oci/rootfs                 /oci "linux/amd64" /out/oci/rootfs:
0.316 Trying to unpack image as an OCI image
0.316 nested manifest: processing [{application/vnd.oci.image.manifest.v1+json sha256:afb32e6e1d58ffc85e2c2310dd22cee8a1b9b0db50b405e3db900c232bc1e2ac 566 [] map[vnd.docker.reference.digest:sha256:1621dc67fa1ef10281df47eef725170c6d7caf103cae442f1084e8344c3f3325 vnd.docker.reference.type:attestation-manifest] [] 0xc00006e3c0 }]
0.318 panic: archive/tar: invalid tar header
0.318
0.318 goroutine 1 [running]:
0.318 main.main()
0.318   /work/cmd/create-spec/main.go:58 +0x5ac
------
container2wasm1996446593:59
--------------------
  58 |     # <vm-rootfs>/oci/initconfig.json : configuration file for init
  59 | >>> RUN mkdir -p /out/oci/rootfs /out/oci/bundle && \
  60 | >>>     IS_WIZER=false && \
  61 | >>>     if test "${OPTIMIZATION_MODE}" = "wizer" ; then IS_WIZER=true ; fi && \
  62 | >>>     NO_VMTOUCH_F=false && \
  63 | >>>     if test "${OPTIMIZATION_MODE}" = "native" ; then NO_VMTOUCH_F=true ; fi && \
  64 | >>>     if test "${NO_VMTOUCH}" != "" ; then NO_VMTOUCH_F="${NO_VMTOUCH}" ; fi && \
  65 | >>>     EXTERNAL_BUNDLE_F=false && \
  66 | >>>     if test "${EXTERNAL_BUNDLE}" = "true" ; then EXTERNAL_BUNDLE_F=true ; fi && \
  67 | >>>     create-spec --debug=${INIT_DEBUG} --debug-init=${IS_WIZER} --no-vmtouch=${NO_VMTOUCH_F} --external-bundle=${EXTERNAL_BUNDLE_F} \
  68 | >>>                 --image-config-path=/oci/image.json \
  69 | >>>                 --runtime-config-path=/oci/spec.json \
  70 | >>>                 --rootfs-path=/oci/rootfs \
  71 | >>>                 /oci "${TARGETPLATFORM}" /out/oci/rootfs
  72 |     RUN if test -f image.json; then mv image.json /out/oci/ ; fi && \
--------------------
ERROR: failed to solve: process "/bin/sh -c mkdir -p /out/oci/rootfs /out/oci/bundle &&     IS_WIZER=false &&     if test \"${OPTIMIZATION_MODE}\" = \"wizer\" ; then IS_WIZER=true ; fi &&     NO_VMTOUCH_F=false &&     if test \"${OPTIMIZATION_MODE}\" = \"native\" ; then NO_VMTOUCH_F=true ; fi &&     if test \"${NO_VMTOUCH}\" != \"\" ; then NO_VMTOUCH_F=\"${NO_VMTOUCH}\" ; fi &&     EXTERNAL_BUNDLE_F=false &&     if test \"${EXTERNAL_BUNDLE}\" = \"true\" ; then EXTERNAL_BUNDLE_F=true ; fi &&     create-spec --debug=${INIT_DEBUG} --debug-init=${IS_WIZER} --no-vmtouch=${NO_VMTOUCH_F} --external-bundle=${EXTERNAL_BUNDLE_F}                 --image-config-path=/oci/image.json                 --runtime-config-path=/oci/spec.json                 --rootfs-path=/oci/rootfs                 /oci \"${TARGETPLATFORM}\" /out/oci/rootfs" did not complete successfully: exit code: 2
exit status 1

Error on building wasm from ubutnu 18.04 docker container

I got the following error when attempting to build an ubuntu 18.04 wasm from a docker container image.
I tried under normal user
I tried under sudo
I tried under root user
I tried to set the RUST_BACKTRACE to 1 but it didn't seem to alter the output so I have no further info. I tried setting it in the container and in the host.

First build

#116 [bochs-dev-packed 1/2] RUN /tools/wasi-vfs/wasi-vfs pack /Bochs/bochs/bochs --mapdir /pack::/minpack -o packed && mkdir /out
#116 66.52 panicked at 'capacity overflow', library/alloc/src/raw_vec.rs:517:5
#116 66.66 thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: the `wasi_vfs_pack_fs` function trapped
#116 66.66 
#116 66.66 Caused by:
#116 66.66     wasm trap: wasm `unreachable` instruction executed
#116 66.66     wasm backtrace:
#116 66.66         0: 0x579ce - <unknown>!<wasm function 543>
#116 66.66         1: 0x5af4f - <unknown>!<wasm function 570>
#116 66.66         2: 0x58cc4 - <unknown>!<wasm function 552>
#116 66.66         3: 0x2e623 - <unknown>!<wasm function 230>
#116 66.66         4: 0x36d30 - <unknown>!<wasm function 294>
#116 66.66         5: 0x3d2bd - <unknown>!<wasm function 331>
#116 66.66         6: 0x51863 - <unknown>!<wasm function 500>
#116 66.66     ', crates/wasi-vfs-cli/src/bin/wasi-vfs.rs:5:32
#116 66.66 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
#116 ERROR: process "/bin/sh -c /tools/wasi-vfs/wasi-vfs pack /Bochs/bochs/bochs --mapdir /pack::/minpack -o packed && mkdir /out" did not complete successfully: exit code: 101
------
 > [bochs-dev-packed 1/2] RUN /tools/wasi-vfs/wasi-vfs pack /Bochs/bochs/bochs --mapdir /pack::/minpack -o packed && mkdir /out:
66.66     wasm backtrace:
66.66         0: 0x579ce - <unknown>!<wasm function 543>
66.66         1: 0x5af4f - <unknown>!<wasm function 570>
66.66         2: 0x58cc4 - <unknown>!<wasm function 552>
66.66         3: 0x2e623 - <unknown>!<wasm function 230>
66.66         4: 0x36d30 - <unknown>!<wasm function 294>
66.66         5: 0x3d2bd - <unknown>!<wasm function 331>
66.66         6: 0x51863 - <unknown>!<wasm function 500>
66.66     ', crates/wasi-vfs-cli/src/bin/wasi-vfs.rs:5:32
66.66 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
------
container2wasm229370506:488
--------------------
 486 |     
 487 |     FROM bochs-dev-${OPTIMIZATION_MODE} AS bochs-dev-packed
 488 | >>> RUN /tools/wasi-vfs/wasi-vfs pack /Bochs/bochs/bochs --mapdir /pack::/minpack -o packed && mkdir /out
 489 |     ARG OUTPUT_NAME
 490 |     RUN mv packed /out/$OUTPUT_NAME
--------------------
ERROR: failed to solve: process "/bin/sh -c /tools/wasi-vfs/wasi-vfs pack /Bochs/bochs/bochs --mapdir /pack::/minpack -o packed && mkdir /out" did not complete successfully: exit code: 101
exit status 1

c2w-net with mapdir

Is it possible to pass --mapdir /mnt/share::./share argument to c2w-net?
I've tried to modify the code to include mapdir argument, but wasmtime refuses to recognize --mapdir as a valid argument unless it's the only argument used.
Using wasmtime 21.0.1.

[Question] Better Performance

Hi,

I'm using riscv64/alpine, it takes ~16 seconds to run hello world code in node on a 4 core 4 GB ram device.

Is it possible to get better performance?

c2w CLI does not work on Container Environments

Trying to run c2w on a Cloud IDE utilising either a Firecracker VM or Docker in its backend results in c2w not working because it tries to mount /rootfs/dev/null which is not permitted by the environment.

This is replicable using Gitpod or CSB.

image

cap-primitives failing to build when using c2w

Using v0.5.2 works fine until a rust package seems to fail to compile. Logs starting at error:

#44 46.10 error[E0061]: this method takes 1 argument but 2 arguments were supplied
#44 46.10   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/cap-primitives-0.24.1/src/rustix/linux/fs/set_times_impl.rs:20:25
#44 46.10    |
#44 46.10 20 |             return file.set_times(
#44 46.10    |                         ^^^^^^^^^
#44 46.10 21 |                 atime.map(SystemTimeSpec::into_std),
#44 46.10 22 |                 mtime.map(SystemTimeSpec::into_std),
#44 46.10    |                 ----------------------------------- unexpected argument of type `Option<fs_set_times::SystemTimeSpec>`
#44 46.10    |
#44 46.10 note: expected `FileTimes`, found `Option<SystemTimeSpec>`
#44 46.10   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/cap-primitives-0.24.1/src/rustix/linux/fs/set_times_impl.rs:21:17
#44 46.10    |
#44 46.10 21 |                 atime.map(SystemTimeSpec::into_std),
#44 46.10    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#44 46.10    = note: expected struct `FileTimes`
#44 46.10                 found enum `Option<fs_set_times::SystemTimeSpec>`
#44 46.10 note: method defined here
#44 46.10   --> /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/fs.rs:695:12
#44 46.10 help: remove the extra argument
#44 46.10    |
#44 46.10 21 -                 atime.map(SystemTimeSpec::into_std),
#44 46.10 21 +                 /* FileTimes */,
#44 46.10    |
#44 46.10 
#44 46.10 error[E0061]: this method takes 1 argument but 2 arguments were supplied
#44 46.10   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/cap-primitives-0.24.1/src/rustix/linux/fs/set_times_impl.rs:34:25
#44 46.10    |
#44 46.10 34 |             return file.set_times(
#44 46.10    |                         ^^^^^^^^^
#44 46.10 35 |                 atime.map(SystemTimeSpec::into_std),
#44 46.10 36 |                 mtime.map(SystemTimeSpec::into_std),
#44 46.10    |                 ----------------------------------- unexpected argument of type `Option<fs_set_times::SystemTimeSpec>`
#44 46.10    |
#44 46.10 note: expected `FileTimes`, found `Option<SystemTimeSpec>`
#44 46.10   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/cap-primitives-0.24.1/src/rustix/linux/fs/set_times_impl.rs:35:17
#44 46.10    |
#44 46.10 35 |                 atime.map(SystemTimeSpec::into_std),
#44 46.10    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#44 46.10    = note: expected struct `FileTimes`
#44 46.10                 found enum `Option<fs_set_times::SystemTimeSpec>`
#44 46.10 note: method defined here
#44 46.10   --> /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/fs.rs:695:12
#44 46.10 help: remove the extra argument
#44 46.10    |
#44 46.10 35 -                 atime.map(SystemTimeSpec::into_std),
#44 46.10 35 +                 /* FileTimes */,
#44 46.10    |
#44 46.10 
#44 46.16    Compiling sha2 v0.9.8
#44 46.21 For more information about this error, try `rustc --explain E0061`.
#44 46.22 error: could not compile `cap-primitives` (lib) due to 2 previous errors
#44 46.22 warning: build failed, waiting for other jobs to finish...
#44 ...

#20 [assets-base 2/3] RUN apt-get update && apt-get install -y git
#20 49.06 Get:14 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [1624 kB]
#20 53.49 Get:15 http://archive.ubuntu.com/ubuntu jammy-updates/multiverse amd64 Packages [50.4 kB]
#20 53.56 Get:16 http://archive.ubuntu.com/ubuntu jammy-updates/restricted amd64 Packages [1635 kB]
#20 ...

#49 [runc-amd64-dev 2/2] RUN --mount=type=cache,target=/root/.cache/go-build     --mount=type=cache,target=/go/pkg/mod     git clone https://github.com/opencontainers/runc.git /go/src/github.com/opencontainers/runc &&     cd /go/src/github.com/opencontainers/runc &&     git checkout "v1.1.10" &&     make static GOARCH=amd64 CC=gcc EXTRA_LDFLAGS='-s -w' BUILDTAGS="" EXTRA_LDFLAGS='-s -w' BUILDTAGS="" &&     mkdir -p /out/ && mv runc /out/runc
#49 26.70 Note: switching to 'v1.1.10'.
#49 26.70 
#49 26.70 You are in 'detached HEAD' state. You can look around, make experimental
#49 26.70 changes and commit them, and you can discard any commits you make in this
#49 26.70 state without impacting any branches by switching back to a branch.
#49 26.70 
#49 26.70 If you want to create a new branch to retain commits you create, you may
#49 26.70 do so (now or later) by using -c with the switch command. Example:
#49 26.70 
#49 26.70   git switch -c <new-branch-name>
#49 26.70 
#49 26.70 Or undo this operation with:
#49 26.70 
#49 26.70   git switch -
#49 26.70 
#49 26.70 Turn off this advice by setting config variable advice.detachedHead to false
#49 26.70 
#49 26.70 HEAD is now at 18a0cb0f VERSION: release 1.1.10
#49 26.76 go build -trimpath -buildmode=pie  -tags " netgo osusergo" -ldflags "-X main.gitCommit=v1.1.10-0-g18a0cb0f -X main.version=1.1.10 -linkmode external -extldflags --static-pie -s -w" -o runc .
#49 DONE 27.9s

#20 [assets-base 2/3] RUN apt-get update && apt-get install -y git
#20 55.99 Get:17 http://archive.ubuntu.com/ubuntu jammy-backports/main amd64 Packages [50.4 kB]
#20 56.24 Get:18 http://archive.ubuntu.com/ubuntu jammy-backports/universe amd64 Packages [28.1 kB]
#20 56.26 Fetched 29.1 MB in 56s (520 kB/s)
#20 56.26 Reading package lists...
#20 CANCELED

#44 [bochs-dev-common  8/25] RUN git clone https://github.com/bytecodealliance/wizer &&     cd wizer &&     git checkout "04e49c989542f2bf3a112d60fbf88a62cce2d0d0" &&     cargo build --bin wizer --all-features &&     mkdir -p /tools/wizer/ &&     mv include target/debug/wizer /tools/wizer/ &&     cargo clean
#44 ERROR: process "/bin/sh -c git clone https://github.com/bytecodealliance/wizer &&     cd wizer &&     git checkout \"${WIZER_VERSION}\" &&     cargo build --bin wizer --all-features &&     mkdir -p /tools/wizer/ &&     mv include target/debug/wizer /tools/wizer/ &&     cargo clean" did not complete successfully: exit code: 101

#37 [tini-amd64-dev 1/5] RUN apt-get update -y && apt-get install -y cmake
#37 CANCELED
------
 > [bochs-dev-common  8/25] RUN git clone https://github.com/bytecodealliance/wizer &&     cd wizer &&     git checkout "04e49c989542f2bf3a112d60fbf88a62cce2d0d0" &&     cargo build --bin wizer --all-features &&     mkdir -p /tools/wizer/ &&     mv include target/debug/wizer /tools/wizer/ &&     cargo clean:
46.10 help: remove the extra argument
46.10    |
46.10 35 -                 atime.map(SystemTimeSpec::into_std),
46.10 35 +                 /* FileTimes */,
46.10    |
46.10 
46.16    Compiling sha2 v0.9.8
46.21 For more information about this error, try `rustc --explain E0061`.
46.22 error: could not compile `cap-primitives` (lib) due to 2 previous errors
46.22 warning: build failed, waiting for other jobs to finish...
------
Dockerfile:435
--------------------
 434 |     WORKDIR /work/
 435 | >>> RUN git clone https://github.com/bytecodealliance/wizer && \
 436 | >>>     cd wizer && \
 437 | >>>     git checkout "${WIZER_VERSION}" && \
 438 | >>>     cargo build --bin wizer --all-features && \
 439 | >>>     mkdir -p /tools/wizer/ && \
 440 | >>>     mv include target/debug/wizer /tools/wizer/ && \
 441 | >>>     cargo clean
 442 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c git clone https://github.com/bytecodealliance/wizer &&     cd wizer &&     git checkout \"${WIZER_VERSION}\" &&     cargo build --bin wizer --all-features &&     mkdir -p /tools/wizer/ &&     mv include target/debug/wizer /tools/wizer/ &&     cargo clean" did not complete successfully: exit code: 101
exit status 1

Scaling or pre-sizing images

How do I resize or configure the size at build? I didn't see much mention of that but perhaps entirely a docker concern and question?

Not working with image >2GB

Hi, I can't seem to get this working when I try to convert a container image built by Nix to WASM. Here's what my Nix expression looks like:

# default.nix
let
  nixpkgs-src = builtins.fetchTarball {
    url = "https://github.com/NixOS/nixpkgs/tarball/7731670498f0a22c361c9d68f73d382bce05d7dc";
    sha256 = "sha256-M59UCWsadEFO+DMdZFMtTlxpFyT3RQIpBLuEX8oziVc=";
  };
  nixpkgs = import nixpkgs-src {};
  haskellEnv = nixpkgs.haskellPackages.ghcWithPackages (p: [ ]);
  image = nixpkgs.dockerTools.buildLayeredImage {
    name = "small-haskell";
    tag = "latest";
    contents =  [
      haskellEnv
      nixpkgs.bashInteractive
    ];
    config = {
      Cmd = ["${haskellEnv}/bin/ghci"];
    };
  };
in image

And here are the commands I'm running:

$ nix-build default.nix
$ docker load < result
$ c2w --version
c2w version v0.6.2
$ c2w small-haskell:latest out.wasm
<...>
#120 [bochs-dev-packed 1/2] RUN /tools/wasi-vfs/wasi-vfs pack /Bochs/bochs/bochs --mapdir /pack::/minpack -o packed && mkdir /out
#120 128.3 panicked at 'capacity overflow', library/alloc/src/raw_vec.rs:517:5
#120 128.4 thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: the `wasi_vfs_pack_fs` function trapped
#120 128.4 
#120 128.4 Caused by:
#120 128.4     wasm trap: wasm `unreachable` instruction executed
#120 128.4     wasm backtrace:
#120 128.4         0: 0x57515 - <unknown>!<wasm function 540>
#120 128.4         1: 0x5aa96 - <unknown>!<wasm function 567>
#120 128.4         2: 0x5880b - <unknown>!<wasm function 549>
#120 128.4         3: 0x2e180 - <unknown>!<wasm function 229>
#120 128.4         4: 0x3688d - <unknown>!<wasm function 293>
#120 128.4         5: 0x3ce1a - <unknown>!<wasm function 330>
#120 128.4         6: 0x513aa - <unknown>!<wasm function 497>
#120 128.4     ', crates/wasi-vfs-cli/src/bin/wasi-vfs.rs:5:32
#120 128.4 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
#120 ERROR: process "/bin/sh -c /tools/wasi-vfs/wasi-vfs pack /Bochs/bochs/bochs --mapdir /pack::/minpack -o packed && mkdir /out" did not complete successfully: exit code: 101
------
 > [bochs-dev-packed 1/2] RUN /tools/wasi-vfs/wasi-vfs pack /Bochs/bochs/bochs --mapdir /pack::/minpack -o packed && mkdir /out:
128.4     wasm backtrace:
128.4         0: 0x57515 - <unknown>!<wasm function 540>
128.4         1: 0x5aa96 - <unknown>!<wasm function 567>
128.4         2: 0x5880b - <unknown>!<wasm function 549>
128.4         3: 0x2e180 - <unknown>!<wasm function 229>
128.4         4: 0x3688d - <unknown>!<wasm function 293>
128.4         5: 0x3ce1a - <unknown>!<wasm function 330>
128.4         6: 0x513aa - <unknown>!<wasm function 497>
128.4     ', crates/wasi-vfs-cli/src/bin/wasi-vfs.rs:5:32
128.4 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
------
container2wasm1665798681:488
--------------------
 486 |     
 487 |     FROM bochs-dev-${OPTIMIZATION_MODE} AS bochs-dev-packed
 488 | >>> RUN /tools/wasi-vfs/wasi-vfs pack /Bochs/bochs/bochs --mapdir /pack::/minpack -o packed && mkdir /out
 489 |     ARG OUTPUT_NAME
 490 |     RUN mv packed /out/$OUTPUT_NAME
--------------------
ERROR: failed to solve: process "/bin/sh -c /tools/wasi-vfs/wasi-vfs pack /Bochs/bochs/bochs --mapdir /pack::/minpack -o packed && mkdir /out" did not complete successfully: exit code: 101
exit status 1

Am I using the tool incorrectly?

Unable to use low-privilege accounts in containers

I used the following Dockerfile to build the test image

FROM ubuntu:22.04

RUN useradd -m test && \
    echo "test:123" | chpasswd

USER test

Once the image is compiled, convert it to a wasm file and start the service, the following error is reported

image

/bin/bash: error while loading shared libraries: libtinfo.so.6: cannot open shared object file: Permission denied

Mac builds?

Do you plan releasing pre-built binaries for (Apple Silicon) Macs?

ERROR: failed to solve: wasi-vfs

I'm building from source on an M1 Mac, using commit 31f6db8.

make
./out/c2w ubuntu:22.04 out.wasm

It appears there is an issue with was-vfs?

#70 [busybox-amd64-dev  6/11] RUN make CROSS_COMPILE=x86_64-linux-gnu- LDFLAGS=--static -j$(nproc)
#70 CANCELED
------
 > [bochs-dev-common  6/25] RUN git clone https://github.com/kateinoigakukun/wasi-vfs.git --recurse-submodules &&     cd wasi-vfs &&     git checkout "v0.3.0" &&     cargo build --target wasm32-unknown-unknown &&     cargo build --package wasi-vfs-cli &&     mkdir -p /tools/wasi-vfs/ &&     mv target/debug/wasi-vfs target/wasm32-unknown-unknown/debug/libwasi_vfs.a /tools/wasi-vfs/ &&     cargo clean:
5.436 info: downloading component 'rust-std' for 'wasm32-wasi'
6.074 info: downloading component 'rust-std'
7.041 info: downloading component 'rustc'
9.959 info: installing component 'cargo'
11.87 info: installing component 'rust-std' for 'wasm32-unknown-unknown'
15.58 info: installing component 'rust-std' for 'wasm32-wasi'
19.38 info: installing component 'rust-std'
25.25 info: installing component 'rustc'
41.87     Updating crates.io index
92.07 Killed
------
Dockerfile:425
--------------------
 424 |     WORKDIR /work/
 425 | >>> RUN git clone https://github.com/kateinoigakukun/wasi-vfs.git --recurse-submodules && \
 426 | >>>     cd wasi-vfs && \
 427 | >>>     git checkout "${WASI_VFS_VERSION}" && \
 428 | >>>     cargo build --target wasm32-unknown-unknown && \
 429 | >>>     cargo build --package wasi-vfs-cli && \
 430 | >>>     mkdir -p /tools/wasi-vfs/ && \
 431 | >>>     mv target/debug/wasi-vfs target/wasm32-unknown-unknown/debug/libwasi_vfs.a /tools/wasi-vfs/ && \
 432 | >>>     cargo clean
 433 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c git clone https://github.com/kateinoigakukun/wasi-vfs.git --recurse-submodules &&     cd wasi-vfs &&     git checkout \"${WASI_VFS_VERSION}\" &&     cargo build --target wasm32-unknown-unknown &&     cargo build --package wasi-vfs-cli &&     mkdir -p /tools/wasi-vfs/ &&     mv target/debug/wasi-vfs target/wasm32-unknown-unknown/debug/libwasi_vfs.a /tools/wasi-vfs/ &&     cargo clean" did not complete successfully: exit code: 137
exit status 1

Mounting files into the container in the browser?

An example is given for mounting files into the container when running on a stand-alone WASI runner, but not in the context of the browser.

If I have a File or a Blob in hand in JavaScript when I am setting up the emulator, how would I expose that to the container at a certain path?

Bonus points if I can also mount something writable, like a resizable ArrayBuffer.

How to approach adding a new network adapter?

Hello! Amazing work on container2wasm.

I recently finished working on https://github.com/3p3r/fakettp/ which is based on Service Workers and allows any client side code to spawn a fake web server or even run socket.io in polling mode.

Using fakettp and socket.io in polling mode, I wanted to add a new network adapter to container2wasm which runs entirely in browser and uses Service Workers underneath. This would also lead to containers being able to communicate with each other in browser entirely.

How do I approach doing that? Where is the best place to start this effort and contribute it back?

WASM Save States

This is a great and awesome project! I've been playing with c2w and although the image build took long on my PC (was trying out vim) I was wondering if this supports save states such that I can modify the WASM file and save it into a WASM file.

Is this possible and is there any advice on how to do this?

Thanks!

c2w ubuntu:24.04 ubuntu-24.04.wasm error

I tried to convert the ubuntu:24.04 image via c2w ubuntu:24.04 ubuntu-24.04.wasm. But it failed with the following errors.

Details
[root@localhost ~]# docker pull ubuntu:24.04
24.04: Pulling from library/ubuntu
49b384cc7b4a: Pull complete 
Digest: sha256:3f85b7caad41a95462cf5b787d8a04604c8262cdcdf9a472b8c52ef83375fe15
Status: Downloaded newer image for ubuntu:24.04
docker.io/library/ubuntu:24.04
[root@localhost ~]# c2w ubuntu:24.04 ubuntu-24.04.wasm
2024/05/21 15:28:19 saving "ubuntu:24.04" to "/tmp/container2wasm2131497631/img"
2024/05/21 15:28:24 buildx args: [buildx build --progress=plain --build-arg TARGETARCH=amd64 --build-arg TARGETPLATFORM=linux/amd64 --platform=linux/amd64 -f /tmp/container2wasm84066038 --output type=local,dest=/root --build-arg OUTPUT_NAME=ubuntu-24.04.wasm --build-arg LINUX_LOGLEVEL=0 --build-arg INIT_DEBUG=false /tmp/container2wasm2131497631/img]
#0 building with "default" instance using docker driver

#1 [internal] load build definition from container2wasm84066038
#1 transferring dockerfile:
#1 transferring dockerfile: 23.46kB 0.1s done
#1 DONE 0.7s

#2 resolve image config for docker.io/docker/dockerfile:1.5
#2 ...

#3 [auth] docker/dockerfile:pull token for registry-1.docker.io
#3 DONE 0.0s

#2 resolve image config for docker.io/docker/dockerfile:1.5
#2 DONE 4.3s

#4 docker-image://docker.io/docker/dockerfile:1.5@sha256:39b85bbfa7536a5feceb7372a0817649ecb2724562a38360f4d6a7782a409b14
#4 resolve docker.io/docker/dockerfile:1.5@sha256:39b85bbfa7536a5feceb7372a0817649ecb2724562a38360f4d6a7782a409b14 0.0s done
#4 sha256:39b85bbfa7536a5feceb7372a0817649ecb2724562a38360f4d6a7782a409b14 8.40kB / 8.40kB done
#4 sha256:966d40f9ba8366e74c2fa353fc0bc7bbc167d2a0f3ad2420db8b9e633049462d 482B / 482B done
#4 sha256:dbdd11720762ad504260c66161c964e59eba06b95a7aa64a68634b598a830a91 2.90kB / 2.90kB done
#4 sha256:a47ff7046597eea0123ea02817165350e3680f75000dc5d69c9a310258e1bedd 0B / 11.55MB 0.1s
#4 sha256:a47ff7046597eea0123ea02817165350e3680f75000dc5d69c9a310258e1bedd 1.05MB / 11.55MB 0.9s
#4 sha256:a47ff7046597eea0123ea02817165350e3680f75000dc5d69c9a310258e1bedd 3.15MB / 11.55MB 1.0s
#4 sha256:a47ff7046597eea0123ea02817165350e3680f75000dc5d69c9a310258e1bedd 6.29MB / 11.55MB 1.2s
#4 sha256:a47ff7046597eea0123ea02817165350e3680f75000dc5d69c9a310258e1bedd 8.39MB / 11.55MB 1.3s
#4 sha256:a47ff7046597eea0123ea02817165350e3680f75000dc5d69c9a310258e1bedd 11.55MB / 11.55MB 1.5s
#4 sha256:a47ff7046597eea0123ea02817165350e3680f75000dc5d69c9a310258e1bedd 11.55MB / 11.55MB 1.5s done
#4 extracting sha256:a47ff7046597eea0123ea02817165350e3680f75000dc5d69c9a310258e1bedd 0.1s
#4 extracting sha256:a47ff7046597eea0123ea02817165350e3680f75000dc5d69c9a310258e1bedd 0.5s done
#4 DONE 2.5s

#5 [internal] load .dockerignore
#5 transferring context: 2B 0.1s done
#5 DONE 0.2s

#6 [internal] load metadata for docker.io/library/ubuntu:22.04
#6 DONE 0.0s

#7 [internal] load metadata for docker.io/library/golang:1.21-bullseye
#7 ...

#8 [auth] library/golang:pull token for registry-1.docker.io
#8 DONE 0.0s

#9 [auth] library/rust:pull token for registry-1.docker.io
#9 DONE 0.0s

#10 [auth] library/ubuntu:pull token for registry-1.docker.io
#10 DONE 0.0s

#11 [internal] load metadata for docker.io/library/rust:1.74.1-buster
#11 ...

#12 [internal] load metadata for docker.io/library/ubuntu:latest
#12 DONE 5.5s

#7 [internal] load metadata for docker.io/library/golang:1.21-bullseye
#7 DONE 5.5s

#11 [internal] load metadata for docker.io/library/rust:1.74.1-buster
#11 DONE 5.7s

#13 [bochs-dev-common  1/25] FROM docker.io/library/rust:1.74.1-buster@sha256:69a9eff032b76f79418e8451c156b7124e0cd89da841554fcde39e9ea0a5e882
#13 resolve docker.io/library/rust:1.74.1-buster@sha256:69a9eff032b76f79418e8451c156b7124e0cd89da841554fcde39e9ea0a5e882 0.0s done
#13 ...

#14 [bios-amd64-dev 1/7] FROM docker.io/library/ubuntu@sha256:3f85b7caad41a95462cf5b787d8a04604c8262cdcdf9a472b8c52ef83375fe15
#14 DONE 0.1s

#13 [bochs-dev-common  1/25] FROM docker.io/library/rust:1.74.1-buster@sha256:69a9eff032b76f79418e8451c156b7124e0cd89da841554fcde39e9ea0a5e882
#13 sha256:69a9eff032b76f79418e8451c156b7124e0cd89da841554fcde39e9ea0a5e882 988B / 988B done
#13 sha256:ca1dad9de65e57a6032fc6cf443e9e1d42a09ef8c4ec11c9fdc11cf58fa44260 1.38kB / 1.38kB done
#13 sha256:80e14f4aaa4adf2875939a88de1ac63d82b6862086ff99dde6873fc695675a6a 6.09kB / 6.09kB done
#13 sha256:30b73a2ffaab3c39355a8bcc5eae8ba1465bd7d9467f197b91f7635816b16bc9 0B / 50.50MB 0.2s
#13 sha256:0b38726aed64a0804777af4106983e9686ea639add75dae8538ecaad0c0e6a58 0B / 17.58MB 0.2s
#13 sha256:ea388039df9c5c51dda7a2d1d6908eac88ae220452b81495739aff1428c1f847 0B / 51.87MB 0.2s
#13 ...

#15 [bochs-config-dev 1/4] FROM docker.io/library/ubuntu:22.04
#15 DONE 0.3s

#13 [bochs-dev-common  1/25] FROM docker.io/library/rust:1.74.1-buster@sha256:69a9eff032b76f79418e8451c156b7124e0cd89da841554fcde39e9ea0a5e882
#13 sha256:0b38726aed64a0804777af4106983e9686ea639add75dae8538ecaad0c0e6a58 1.05MB / 17.58MB 3.2s
#13 sha256:0b38726aed64a0804777af4106983e9686ea639add75dae8538ecaad0c0e6a58 2.10MB / 17.58MB 3.6s
#13 sha256:0b38726aed64a0804777af4106983e9686ea639add75dae8538ecaad0c0e6a58 3.13MB / 17.58MB 4.1s
#13 sha256:ea388039df9c5c51dda7a2d1d6908eac88ae220452b81495739aff1428c1f847 3.15MB / 51.87MB 4.1s
#13 sha256:0b38726aed64a0804777af4106983e9686ea639add75dae8538ecaad0c0e6a58 4.19MB / 17.58MB 4.4s
#13 sha256:30b73a2ffaab3c39355a8bcc5eae8ba1465bd7d9467f197b91f7635816b16bc9 1.05MB / 50.50MB 5.4s
#13 sha256:0b38726aed64a0804777af4106983e9686ea639add75dae8538ecaad0c0e6a58 7.34MB / 17.58MB 5.4s
#13 sha256:ea388039df9c5c51dda7a2d1d6908eac88ae220452b81495739aff1428c1f847 9.44MB / 51.87MB 5.4s
#13 sha256:0b38726aed64a0804777af4106983e9686ea639add75dae8538ecaad0c0e6a58 8.39MB / 17.58MB 5.5s
#13 sha256:0b38726aed64a0804777af4106983e9686ea639add75dae8538ecaad0c0e6a58 10.49MB / 17.58MB 5.6s
#13 ...

#16 [bios-amd64-dev 2/7] RUN apt-get update && apt-get install -y build-essential
#16 ERROR: process "/bin/sh -c apt-get update && apt-get install -y build-essential" did not complete successfully: failed to create endpoint vh6aabslshu1ylmqye2xv1xk8 on network bridge: failed to add the host (veth29ccddf) <=> sandbox (veth73bd838) pair interfaces: cannot allocate memory

#13 [bochs-dev-common  1/25] FROM docker.io/library/rust:1.74.1-buster@sha256:69a9eff032b76f79418e8451c156b7124e0cd89da841554fcde39e9ea0a5e882
#13 ...

#17 [internal] load build context
#17 transferring context: 16.98MB 5.8s
#17 ...

#13 [bochs-dev-common  1/25] FROM docker.io/library/rust:1.74.1-buster@sha256:69a9eff032b76f79418e8451c156b7124e0cd89da841554fcde39e9ea0a5e882
#13 ...

#18 [golang-base 1/1] FROM docker.io/library/golang:1.21-bullseye@sha256:6815d296f20c3cb3afa67bf5dc862a831b6080f5dd8b5b423bb5f862539299de
#18 resolve docker.io/library/golang:1.21-bullseye@sha256:6815d296f20c3cb3afa67bf5dc862a831b6080f5dd8b5b423bb5f862539299de 0.1s done
#18 sha256:a07117191dd06486b472d53afb6db7102e663da37ee82b573d17f547edbaefb8 2.83kB / 2.83kB done
#18 sha256:6815d296f20c3cb3afa67bf5dc862a831b6080f5dd8b5b423bb5f862539299de 9.10kB / 9.10kB done
#18 sha256:c5122d2f8e2cae82d7c65140a298031c4b0201f44012e40aa96060f96e94a58f 2.32kB / 2.32kB done
#18 CANCELED

#13 [bochs-dev-common  1/25] FROM docker.io/library/rust:1.74.1-buster@sha256:69a9eff032b76f79418e8451c156b7124e0cd89da841554fcde39e9ea0a5e882
#13 sha256:30b73a2ffaab3c39355a8bcc5eae8ba1465bd7d9467f197b91f7635816b16bc9 4.19MB / 50.50MB 6.6s
#13 ...

#17 [internal] load build context
#17 transferring context: 17.84MB 6.1s done
#17 CANCELED

#13 [bochs-dev-common  1/25] FROM docker.io/library/rust:1.74.1-buster@sha256:69a9eff032b76f79418e8451c156b7124e0cd89da841554fcde39e9ea0a5e882
#13 sha256:0b38726aed64a0804777af4106983e9686ea639add75dae8538ecaad0c0e6a58 11.53MB / 17.58MB 8.5s
#13 ...

#19 [gcc-x86-64-linux-gnu-base 2/2] RUN apt-get update && apt-get install -y gcc-x86-64-linux-gnu linux-libc-dev-amd64-cross git make
#19 ...

#20 [assets-base 2/3] RUN apt-get update && apt-get install -y git
#20 ...

#21 [rootfs-amd64-dev  2/10] RUN apt-get update -y && apt-get install -y mkisofs
#21 ...

#22 [bochs-config-dev 2/4] RUN apt-get update && apt-get install -y gettext-base && mkdir /out
#22 ...

#13 [bochs-dev-common  1/25] FROM docker.io/library/rust:1.74.1-buster@sha256:69a9eff032b76f79418e8451c156b7124e0cd89da841554fcde39e9ea0a5e882
#13 sha256:ea388039df9c5c51dda7a2d1d6908eac88ae220452b81495739aff1428c1f847 12.58MB / 51.87MB 9.7s
#13 sha256:30b73a2ffaab3c39355a8bcc5eae8ba1465bd7d9467f197b91f7635816b16bc9 17.83MB / 50.50MB 32.0s
#13 sha256:0b38726aed64a0804777af4106983e9686ea639add75dae8538ecaad0c0e6a58 17.58MB / 17.58MB 32.0s
#13 sha256:ea388039df9c5c51dda7a2d1d6908eac88ae220452b81495739aff1428c1f847 23.07MB / 51.87MB 32.0s
#13 sha256:0b38726aed64a0804777af4106983e9686ea639add75dae8538ecaad0c0e6a58 17.58MB / 17.58MB 34.1s done
#13 sha256:0dd4fbda45c5750b2808bd8a3385ffd64974432821cfa42ae41da8450163d1f1 0B / 191.91MB 34.6s
#13 sha256:30b73a2ffaab3c39355a8bcc5eae8ba1465bd7d9467f197b91f7635816b16bc9 20.97MB / 50.50MB 35.7s
#13 sha256:30b73a2ffaab3c39355a8bcc5eae8ba1465bd7d9467f197b91f7635816b16bc9 29.36MB / 50.50MB 37.4s
#13 sha256:ea388039df9c5c51dda7a2d1d6908eac88ae220452b81495739aff1428c1f847 33.55MB / 51.87MB 37.4s
#13 ...

#19 [gcc-x86-64-linux-gnu-base 2/2] RUN apt-get update && apt-get install -y gcc-x86-64-linux-gnu linux-libc-dev-amd64-cross git make
#19 CANCELED

#13 [bochs-dev-common  1/25] FROM docker.io/library/rust:1.74.1-buster@sha256:69a9eff032b76f79418e8451c156b7124e0cd89da841554fcde39e9ea0a5e882
#13 sha256:30b73a2ffaab3c39355a8bcc5eae8ba1465bd7d9467f197b91f7635816b16bc9 32.51MB / 50.50MB 39.7s
#13 sha256:ea388039df9c5c51dda7a2d1d6908eac88ae220452b81495739aff1428c1f847 37.75MB / 51.87MB 39.7s
#13 sha256:0dd4fbda45c5750b2808bd8a3385ffd64974432821cfa42ae41da8450163d1f1 0B / 191.91MB 39.7s
#13 sha256:30b73a2ffaab3c39355a8bcc5eae8ba1465bd7d9467f197b91f7635816b16bc9 35.07MB / 50.50MB 40.2s
#13 sha256:ea388039df9c5c51dda7a2d1d6908eac88ae220452b81495739aff1428c1f847 40.89MB / 51.87MB 40.4s
#13 sha256:30b73a2ffaab3c39355a8bcc5eae8ba1465bd7d9467f197b91f7635816b16bc9 38.80MB / 50.50MB 40.7s
#13 ...

#21 [rootfs-amd64-dev  2/10] RUN apt-get update -y && apt-get install -y mkisofs
#21 CANCELED

#13 [bochs-dev-common  1/25] FROM docker.io/library/rust:1.74.1-buster@sha256:69a9eff032b76f79418e8451c156b7124e0cd89da841554fcde39e9ea0a5e882
#13 sha256:30b73a2ffaab3c39355a8bcc5eae8ba1465bd7d9467f197b91f7635816b16bc9 41.94MB / 50.50MB 40.8s
#13 sha256:ea388039df9c5c51dda7a2d1d6908eac88ae220452b81495739aff1428c1f847 45.09MB / 51.87MB 40.8s
#13 sha256:30b73a2ffaab3c39355a8bcc5eae8ba1465bd7d9467f197b91f7635816b16bc9 46.88MB / 50.50MB 41.2s
#13 sha256:ea388039df9c5c51dda7a2d1d6908eac88ae220452b81495739aff1428c1f847 49.28MB / 51.87MB 41.2s
#13 sha256:ea388039df9c5c51dda7a2d1d6908eac88ae220452b81495739aff1428c1f847 51.87MB / 51.87MB 41.8s done
#13 sha256:0dd4fbda45c5750b2808bd8a3385ffd64974432821cfa42ae41da8450163d1f1 10.49MB / 191.91MB 42.0s
#13 sha256:416e1b8c4c0326712124efdb1ea763c0c0ddce6d3c05805c2303ce5908d8c46f 0B / 171.12MB 42.6s
#13 sha256:416e1b8c4c0326712124efdb1ea763c0c0ddce6d3c05805c2303ce5908d8c46f 9.44MB / 171.12MB 45.2s
#13 CANCELED

#22 [bochs-config-dev 2/4] RUN apt-get update && apt-get install -y gettext-base && mkdir /out
#22 42.94 runc run failed: container process is already dead
#22 CANCELED

#20 [assets-base 2/3] RUN apt-get update && apt-get install -y git
#20 48.97 runc run failed: container process is already dead
#20 CANCELED
------
 > [bios-amd64-dev 2/7] RUN apt-get update && apt-get install -y build-essential:
------
container2wasm84066038:373
--------------------
 371 |     
 372 |     FROM ubuntu AS bios-amd64-dev
 373 | >>> RUN apt-get update && apt-get install -y build-essential
 374 |     COPY --link --from=assets ./patches/bochs/Bochs /Bochs
 375 |     WORKDIR /Bochs/bochs
--------------------
ERROR: failed to solve: process "/bin/sh -c apt-get update && apt-get install -y build-essential" did not complete successfully: failed to create endpoint vh6aabslshu1ylmqye2xv1xk8 on network bridge: failed to add the host (veth29ccddf) <=> sandbox (veth73bd838) pair interfaces: cannot allocate memory
exit status 1
[root@localhost ~]# 

Web proxy CORS solution

Got browser proxy working around CORS. I used CORS chrome extension, which you can study and integrate into your service worker js and/or Apache config

Basically did a couple of things. I stripped 'cache-control' from your Apache header, I set Access-Control-Allow-Origin: to *, and Allow-Control-Allow-Headers to 'include' and CORS errors WHILE using browser-based proxy wasm parallel to main image works without CORS errors and Fetch works. Maybe you already knew this but seemed worth mentioning.

Also I noticed another similar CORS block in similar use case and I think simply having c2w listening over SSL/TLS or at the page/browser its presented on, can eliminate these CORS denials under a lesser known policy or non-header property called CORS 'isolation' required for sharedMemoryBuffer.

Error response from daemon: unable to create manifests file

I compiled c2w on macos and ran the following but got errors:

$ c2w ubuntu:22.04 out.wasm
2024/04/16 10:59:22 saving "ubuntu:22.04" to "/var/folders/wn/gz14l4x91dbfq8byk2tmw33h0000gn/T/container2wasm1995291679/img"
Error response from daemon: unable to create manifests file: content digest sha256:c427cc251a507a2459eacd770fe2cd7e451f883b077e09b2d27fa6f129b29d81: not found
failed to prepare image: exit status 1

My Docker is Docker Desktop for Mac

GUI support

Any plans to support virtual displays? Perhaps via WebGPU?

Graphical support

I think that using container2wasm could be a great way to preserve software. There is a good setup right now for linux terminal applications.

Are there any ideas for graphical applications?

Having X11 support especially in the browser would enable a large set of applications to be preserved.

Do not mimimize a docker image during conversion

Hello!

It is more of a feature request rather than an issue.

I am converting a custom image (built on top of ubuntu:22.04 docker image) using command c2w as follows:

c2w custom-image:latest out.wasm

This custom-image is built in such a way that man command works and even sudo command is available for the user (also created in Dockerfile for the custom-image).

But after conversion I get the following:

  • When I run man command, I get
This system has been minimized by removing packages and content that are
not required on a system that users do not log into.
    
To restore this content, including manpages, you can run the 'unminimize'
command. You will still need to ensure the 'man-db' package is installed.
  • When I try to use sudo -s, I get
sudo: The "no new privileges" flag is set, which prevents sudo from running as root.
sudo: If sudo is running in a container, you may need to adjust the container configuration to disable the flag.

Both commands work fine if I just run this image in a docker container (via docker run ...).

I can probably live without sudo, but man is a necessity for my project.

I assume the image is being modified during conversion. Is it possible avoid this conversion and tell c2w command to just use the image as is without any modifications. Or there is a reason for this that cannot be avoided?

Thank you very much in advance for your help.

Suggestion: Allow passing env.variables when calling `c2w-net`

I know that you can pass env. variables when calling wasmtime and I saw that there's one env. variable passed to wasmtime by c2w-net but running your image might need some custom env. variables to be passed to it.

It would be great if there's an option in c2w-net to allow this.

Proxy cert issue

I am sorry for so many issues at the same time.

I set up network mode through Fetch (net=browser). But when I try to do curl for a site that I assume allows CORS, I get the following error:

learner@:~$ curl https://raw.githubusercontent.com/Blahah/command_line_bootcamp/master/testfiles/grades.txt
curl: (77) error setting certificate file: /.wasmenv/proxy.crt

I can see that the directory /.wasmenv exist, but I cannot check what is inside as it has effectively zero permission:

0 d---------  1 root    root       0 Jan  1  1970 .wasmenv

Is it me or there is something horribly wrong happened during WASM image creation/conversion?

Thank you very much in advance.

Failed (`could not compile cap-primitives (lib) due to 2 previous errors`)

what I did:

$ c2w -v
c2w version 0.5.2
$ tree /tmp/testctx/
/tmp/testctx
├── Dockerfile
├── requirements.txt
└── test.py
$ cat /tmp/testctx/Dockerfile
FROM python:3

WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY test.py .

CMD ["python", "test.py"]
$ cat /tmp/testctx/test.py 
print("Hello, world");
$ docker build -t test-py /tmp/testctx/
$ c2w --target-arch=amd64 test-py /tmp/out/python.wasm

log:

#50 [bochs-dev-common  8/25] RUN git clone https://github.com/bytecodealliance/wizer &&     cd wizer &&     git checkout "04e49c989542f2bf3a112d60fbf88a62cce2d0d0" &&     cargo build --bin wizer --all-features &&     mkdir -p /tools/wizer/ &&     mv include target/debug/wizer /tools/wizer/ &&     cargo clean
#50 ERROR: process "/bin/sh -c git clone https://github.com/bytecodealliance/wizer &&     cd wizer &&     git checkout \"${WIZER_VERSION}\" &&     cargo build --bin wizer --all-features &&     mkdir -p /tools/wizer/ &&     mv include target/debug/wizer /tools/wizer/ &&     cargo clean" did not complete successfully: exit code: 101

#49 [linux-amd64-dev 4/4] RUN make ARCH=x86 CROSS_COMPILE=x86_64-linux-gnu- -j$(nproc) all &&     mkdir /out &&     mv /work-buildlinux/linux/arch/x86/boot/bzImage /out/bzImage &&     make clean
#49 427.0   CC      arch/x86/kernel/ptrace.o
#49 CANCELED
------
 > [bochs-dev-common  8/25] RUN git clone https://github.com/bytecodealliance/wizer &&     cd wizer &&     git checkout "04e49c989542f2bf3a112d60fbf88a62cce2d0d0" &&     cargo build --bin wizer --all-features &&     mkdir -p /tools/wizer/ &&     mv include target/debug/wizer /tools/wizer/ &&     cargo clean:
287.7    Compiling fs-set-times v0.15.0
288.8    Compiling object v0.26.2
297.9    Compiling wasmtime-runtime v0.35.3
300.8    Compiling ittapi-rs v0.2.0
301.3    Compiling ipnet v2.3.1
302.0    Compiling cpp_demangle v0.3.3
304.1    Compiling maybe-owned v0.3.4
304.2    Compiling rustc-demangle v0.1.21
: could not compile `cap-primitives` (lib) due to 2 previous errors
308.4 warning: build failed, waiting for other jobs to finish...
------
Dockerfile:435
--------------------
 434 |     WORKDIR /work/
 435 | >>> RUN git clone https://github.com/bytecodealliance/wizer && \
 436 | >>>     cd wizer && \
 437 | >>>     git checkout "${WIZER_VERSION}" && \
 438 | >>>     cargo build --bin wizer --all-features && \
 439 | >>>     mkdir -p /tools/wizer/ && \
 440 | >>>     mv include target/debug/wizer /tools/wizer/ && \
 441 | >>>     cargo clean
 442 |
--------------------
ERROR: failed to solve: process "/bin/sh -c git clone https://github.com/bytecodealliance/wizer &&     cd wizer &&     git checkout \"${WIZER_VERSION}\" &&     cargo build --bin wizer --all-features &&     mkdir -p /tools/wizer/ &&     mv include target/debug/wizer /tools/wizer/ &&     cargo clean" did not complete successfully: exit code: 101
exit status 1

Failed to build qemu-tci on emscripten.

Description

I tried to use the qemu-tci on emscripten on the commit: 788e909, and followed the commands of the README.md.

However, I got an error exec /bin/sh: no such file or directory as follows when I executed ./out/c2w --assets=. --to-js --build-arg OPTIMIZATION_MODE=native --target-arch=aarch64 alpine:3.19 /tmp/out-js4/htdocs/, and it seems that I failed to execute /bin/sh in the ubuntu:22.04 base image.

Could you give me some advice?🙏

Error details
...
#19 [rootfs-aarch64-dev 2/9] RUN apt-get update -y && apt-get install -y mkisofs
#19 0.210 exec /bin/sh: no such file or directory
#19 ERROR: process "/bin/sh -c apt-get update -y && apt-get install -y mkisofs" did not complete successfully: exit code: 1

#20 [gcc-aarch64-linux-gnu-base 2/2] RUN apt-get update && apt-get install -y gcc-aarch64-linux-gnu linux-libc-dev-arm64-cross git make
#20 0.221 exec /bin/sh: no such file or directory
#20 ERROR: process "/bin/sh -c apt-get update && apt-get install -y gcc-aarch64-linux-gnu linux-libc-dev-arm64-cross git make" did not complete successfully: exit code: 1

#13 [golang-base 1/1] FROM docker.io/library/golang:1.21-bullseye@sha256:6815d296f20c3cb3afa67bf5dc862a831b6080f5dd8b5b423bb5f862539299de
#13 sha256:3d53ef4019fc129ba03f90790f8f7f28fd279b9357cf3a71423665323b8807d3 55.10MB / 55.10MB 6.7s done
#13 CANCELED

#17 [glib-emscripten-base 1/6] FROM docker.io/emscripten/emsdk:3.1.40@sha256:c1e807a6e03ac5bd5b37bae2ace3c46c08579e2ddeb951037a3b8dac7067f2cc
#17 sha256:8b795d8f70cabbff9c390138dc5ec98b1d2cf5c8af157991ed028b2fce6292ba 247.49MB / 397.30MB 6.7s
#17 sha256:a128c619347831c893bb6823ab47c91deb0591459722f505047f74247949fc41 203.42MB / 225.32MB 6.7s
------
 > [gcc-aarch64-linux-gnu-base 2/2] RUN apt-get update && apt-get install -y gcc-aarch64-linux-gnu linux-libc-dev-arm64-cross git make:
0.221 exec /bin/sh: no such file or directory
------
------
 > [rootfs-aarch64-dev 2/9] RUN apt-get update -y && apt-get install -y mkisofs:
0.210 exec /bin/sh: no such file or directory
------
Dockerfile:298
--------------------
 296 |     
 297 |     FROM ubuntu:22.04 AS gcc-aarch64-linux-gnu-base
 298 | >>> RUN apt-get update && apt-get install -y gcc-aarch64-linux-gnu linux-libc-dev-arm64-cross git make
 299 |     
 300 |     FROM gcc-aarch64-linux-gnu-base AS linux-aarch64-dev-common
--------------------
ERROR: failed to solve: process "/bin/sh -c apt-get update && apt-get install -y gcc-aarch64-linux-gnu linux-libc-dev-arm64-cross git make" did not complete successfully: exit code: 1
exit status 1

Environment

$ lsb_release -a
Linux *** 6.5.0-35-generic #35~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May  7 11:19:33 UTC 2 aarch64 aarch64 aarch64 GNU/Linux

$ go version
go version go1.20 linux/arm64

$ docker --version
Docker version 26.1.3, build b72abbb

$ docker buildx version
github.com/docker/buildx v0.14.0 171fcbe

Wasmer Freezes Up

Hi,

When I try in Wasmer I get no response:

@cemalgnlts ➜ /workspaces/codespaces-blank $ time wasmtime riscv-node.wasm
Welcome to Node.js v18.16.0.

Type ".help" for more information.
> .exit
.exit

real    0m13.176s
user    0m10.205s
sys     0m0.213s

@cemalgnlts ➜ /workspaces/codespaces-blank $ time wasmer run riscv-node.wasm 
^C
real    0m39.833s
user    0m0.087s
sys     0m0.143s

@cemalgnlts ➜ /workspaces/codespaces-blank $ 

How to setup HTTP server running inside container?

I would like to know how it would be possible to expose an HTTP server running inside the container to the outside page so that an iframe running on the same browser tab could potentially make a request to the container.

For instance let's say that my container is running nodejs with express like so:

const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => {
  res.send('Hello World!')
})

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)
})

Is that something that is even possible without some sort of proxy server?
I would like to keep everything running locally.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.