Run an ASP.NET Core App on Raspberry Pi With Docker

Adam Prescott
2 min readFeb 27, 2020

In my last article, I wrote about how to create a single-page Angular app using the .NET Core CLI, create a Docker image, and run it as a container in about 4 steps that take just minutes to execute. By modifying a single line in your Dockerfile, you can target the 32-bit ARM architecture needed to run the image as a container on a Raspberry Pi.

Here’s the one line — the first line — that needs to change in the Dockerfile to make it runnable on ARM32 (old line is commented for reference):

# FROM AS base
FROM AS base

FROM AS build
COPY ["my-app.csproj", "./"]
RUN dotnet restore "./my-app.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "my-app.csproj" -c Release -o /app/build
RUN apt-get update && \
apt-get install -y wget && \
apt-get install -y gnupg2 && \
wget -qO- | bash - && \
apt-get install -y build-essential nodejs

FROM build AS publish
RUN dotnet publish "my-app.csproj" -c Release -o /app/publish

FROM base AS final
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "my-app.dll"]

Note that the official list of available tags for different architectures can be found here. Consult this list to determine if newer images are available.

That’s it, though. Create your image, push it to Docker Hub, pull it on your Raspberry Pi, and run it just as you would locally. If you haven’t used Docker Hub before, you’ll need to login and create a repository. Check out the Docker Hub Quickstart for help. You may also need to run docker login on both machines to access your new repo.

# dev machine
docker build -t <dockerID>/repo .
docker push <dockerID>/repo

# raspberry pi
docker pull <dockerID>/repo
docker run -d -p 5000:80 <dockerID>/repo

Originally published at on February 27, 2020.