Search code examples
c#dockerarm

Create image and deploy ASP.NET Core .NET 5 Docker image to ARM


I built a Net Core 5 Web API in .Net 5 Docker Image and was searching for a way to run create container from that image on ARM v7 Processors like Tinker Board with Debian on it.


Solution

  • Lastly, on the following website, I found the base for building and running the app on ARM Processors: https://hub.docker.com/_/microsoft-dotnet-aspnet

    Scroll down on the page to 'Full Tag Listing' and select base for your architecture.

    You just need to change the base'FROM ...'(in DockerFile) according to your processor architecture and run the Docker build command and an image will be build specifically for your ARM or any other Device.

    For ex. I am running docker container on Tinker Board with Debian installed on it and current .NET Runtime is .NET 5, so my Dockerfile look like this:

    Don't copy blindly. Read the above text first.

    # Base for Debian ARM Linux
    FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim-arm32v7 AS base
    # Setting working directory
    WORKDIR /app
    # Copy the files from Release Folder to working directory
    COPY ./bin/Release/net5.0/. /app/
    # Entrypoint of the app. change app.dll to the name of your project.
    ENTRYPOINT ["dotnet", "app.dll"]
    

    Btw. To minimize the size of the docker image, I built a release version on the development machine and instead of copying the project file into the image, i just copy the file from the RELEASE Folder.