Skip to content

Vinz68/dotnet8-containerized-tryouts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to 'dotnet8-containerized-tryouts'

This is a repo for users getting started with .NET 8 and Docker. The focus is building (simple) .NET 8 application(s) which would run as a container (on Docker) and how to do this. Example serves different use cases and some could serve as a starter template.

Examples

folder/example description extra info and links
hello-dotnet-container console output of OS & computer architecture see also video and original source on github for detailed information
WorkerServiceNet8 Background service with structured logging (serilog) see also serilog webpage

Environment

To build and execute the examples on docker, you need:

The following environment was used for the examples.

  • Windows 11 computer, with following dotnet and docker versions:
$ dotnet --version
8.0.100
$ docker --version
Docker version 24.0.7, build afdd53b

Building

You can try it out on the command line in one of the example folders (as listed in the table), and then ...

Containerize an application

cd [example-project]
dotnet publish -t:PublishContainer

Look inside the container

docker run -it --rm --entrypoint /bin/bash hello-dotnet-container:latest
app@f7c2c6eb7b25:/app$ whoami
app

app@f7c2c6eb7b25:/app$ ls
hello-dotnet-container.deps.json  hello-dotnet-container.exe  hello-dotnet-container.runtimeconfig.json
hello-dotnet-container.dll        hello-dotnet-container.pdb

app@f7c2c6eb7b25:/app$ exit

Show container id and its size

docker image list [example-project]

example output

REPOSITORY               TAG       IMAGE ID       CREATED          SIZE
hello-dotnet-container   latest    bbf52cfe7ff0   11 seconds ago   85.7MB

Run

Launch a container

docker run --rm [example-project]

example

docker run --rm hello-dotnet-container

Hello dot-net-container
OSDescription: Debian GNU/Linux 12 (bookworm)
OSArchitecture: X64!

Extra info

.NET container samples

Docker Run docs

Chiseled Containers

Cross-compilation

OCI image publish

About

.net8 code tryouts, focus on running as container (Docker)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published