question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lighter and faster process for .NET containerization without a container runtime

See original GitHub issue

What should we add or change to make your life better?

We should include konet’s ideas into Tye to make containerization of .NET apps more easy, lightweight and faster without requiring a container runtime, Dockerfiles or downloading base images.

Why is this important to you?

Tye is already able to automatically generate Dockerfiles, what helps with quicker deployments and removes the need to manually maintain a Dockerfile. Having a dependency on Docker as a container runtime however slows down the containerization process and makes it more heavyweight. This slows down development cycles and CI/CD automation.

These problems have been addressed by popular tools like Jib for Java and ko for Go. Recently, I created konet to bring these benefits to the .NET ecosystem.

Including konet’s ideas into Tye would make containerization of .NET apps more easy, lightweight and a faster without requiring a container runtime. Creating multi-arch and multi-OS container images for .NET apps would be a breeze.

konet works by creating binaries for different platforms and architectures by running dotnet build and pushes only those binaries as new tarball layers to a container image registry with a reference to a .NET base image - all without pulling base images, creating Dockerfiles or installing container runtimes.

Performance comparison

Below is a performance comparison for building and pushing a .NET Hello World console application on Linux and on Windows:

image image

In these diagrams, “Cold” means that there was nothing cached, i.e. no base images, no build cache, no .NET build objects and no images in the container registry. “Warm” represents a scenario where the image has already been build and pushed before, so re-building after a change in the source code can use existing base images, build cache, .NET build objects and layer blobs in the container registry.

Both on Linux and Windows konet is faster compared to a traditional process with Docker. The reasons for that are as follows:

  • Docker packs the source code into a tarball and sends it to the Docker Engine for building.
  • Docker pulls the .NET SDK and the .NET runtime container image.
  • Docker creates a container to run the dotnet build command and creates a snapshot afterwards which adds additional overhead.

konet doesn’t have these shortcomings. It builds the image using the local .NET SDK, without the need of pulling a .NET SDK image. When pushing the image, it only references the .NET runtime image as the base image without pulling it before. Only a tarball containing the binaries is uploaded to the container registry.

More information GitHub repo: https://github.com/lippertmarkus/konet More details on how it works (where I reused some content from for this issue): https://lippertmarkus.com/2022/05/21/dotnet-konet/

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:8
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
lippertmarkuscommented, Jul 20, 2022

For running and testing locally (e.g. tye run with --docker param or when config contains other docker services), you would still need a container runtime and the base images to run the created image. So in this scenario, you would “only” benefit from the shorter build times.

I think there are also a lot of users who develop and debug locally without containers and afterwards just want to run tye publish or even tye deploy to quickly test within a real cluster. Those would get the additional benefits of not needing to pull base images and having a container runtime.

So in both scenarios there would be advantages, and it’s also great to say “you only need docker (or another container runtime) if you want to test your container images locally or if you run other services as containers” instead of “docker is a hard requirement if you want to use tye”.

1reaction
imjasonhcommented, Aug 6, 2022

@schmitch both ko and Jib allow the user to configure the base image, with the minimal base image only as a default. Konet and tye should easily be able to do the same.

Read more comments on GitHub >

github_iconTop Results From Across the Web

9 Tips for Containerizing Your .NET Application
First, Docker containers can act as isolated test environments. .NET developers can code and test locally while ensuring consistency between development and ...
Read more >
Comparing Container Runtimes: containerd vs. Docker
containerd is a lightweight container runtime, suitable either for limited-resource computing environments or when you're using a container ...
Read more >
How to Build a Docker Engine-like Custom Container ...
To launch a container, Docker Creates a Runtime Spec file for runC, and then runC uses that to launch the container. runC creates...
Read more >
When to choose .NET 7 for Docker containers
That way, because the .NET Framework is already installed and shared across processes, processes are light and fast to start. However, if you ......
Read more >
What is Containerization?
Containerization is a software deployment process that bundles an application's code with all the files and libraries it needs to run on any...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found