mirror of
https://github.com/containers/crun.git
synced 2026-02-05 15:45:25 +01:00
Mono crun handler man page contains incorrect reference of `wasm` in headings. Signed-off-by: Aditya R <arajan@redhat.com>
1.9 KiB
1.9 KiB
mono windows dotnet handler
- Make sure oci config contains handler for mono or image contains annotation run.oci.handler=dotnet.
- Entrypoint must point to a valid .exe (windows .NET compatible executable).
...
"annotations": {
"run.oci.handler": "dotnet"
},
...
Examples
Compile and run mono compatible dotnet executables inside containers natively
- Following example is using
monoto compile a cross platform executable but you can also use visual studio or any other build tools on windows. - Add relevant function to
hello.csfor this example we will be using a print.
using System;
using System.Runtime.CompilerServices;
class MonoEmbed {
static int Main ()
{
System.Console.WriteLine("hello");
return 0;
}
}
- Compile a new
.exeusingmcs -out:hello.exe hello.csif you havemonoor you canVisualStudioordotnet buildas specified here: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-build - Create relevant image and use your container manager. But for this example we will be running directly using crun and plub config manually.
$ crun run container-with-mono
hello
Running OCI mono compat images with buildah and podman
- Compile your
.exemodule using instructions from step one. - Prepare a
Containerfilewith your.exe.
FROM scratch
COPY hello.exe /
CMD ["/hello.exe"]
- Build wasm image using buildah with annotation
run.oci.handler=dotnet
$ buildah build --annotation "run.oci.handler=dotnet" -t my-windows-executable .
- Make sure your podman points to oci runtime
crunbuild withmonosupport. - Run image using podman
$ podman run --userns=keep-id my-windows-executable:latest
hello
Known-Issues
- Crun-mono containers needs user namespace for containers so with podman use
--userns=autoor--userns=keep-id.