I have a Docker Swarm with multiple Raspberry Pis (raspbian light). I try to run
ASP.NET Core Containers on them as service / stack.
I have following Dockerfile:
FROM microsoft/dotnet:2.0-sdk AS build
WORKDIR /source
COPY WebApi.csproj .
RUN dotnet restore
COPY . .
RUN dotnet publish -c Release -o /publish -r linux-arm /p:PublishWithAspNetCoreTargetManifest="false"
FROM microsoft/dotnet:2.0-runtime-deps-stretch-arm32v7
ENV ASPNETCORE_URLS http://+:80
WORKDIR /app
COPY --from=build /publish .
ENTRYPOINT [ "./WebApi" ]
What works:
Building & pushing the container image on my win10 laptop (till the sdk image is only available for x64) and running the container on a single raspberry node with docker run:
docker run --rm -it myrepo/myimage
Hosting environment: Production
Content root path: /app
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.
(so the container can run and it's no arm vs x64 issue)
What don't work:
docker service create myrep/myimage
2n4ahyhgb3ju5rvo97tekh9vg
overall progress: 0 out of 1 tasks
1/1: no suitable node (unsupported platform on 3 nodes)
And of course docker stack deploy.
If I inspect the created image (or even the arm32v7 image from microsoft) it just states amd64 instead of arm.
"Architecture": "amd64",
"Os": "linux",
So is it a case of wrong meta data? Which is only checked by docker if you use swarm? How can I change that / make it run? Building a base image on my own? Do I miss something?
Edit 1
I tried it with the .NET Core 2.1 images and had the same behavior.
With the latest .NET Core 2.1 Preview 2 images released yesterday it finally works.
Update (add Dockerfile):
This simple one should do the trick:
FROM microsoft/dotnet:2.1-sdk-stretch-arm32v7 AS builder
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1
WORKDIR /src
COPY *.csproj .
RUN dotnet restore
COPY . .
RUN dotnet publish -c Release -o /publish -r linux-arm
FROM microsoft/dotnet:2.1-runtime-deps-stretch-slim-arm32v7
WORKDIR /app
COPY --from=builder /publish .
ENTRYPOINT [ "./MyService" ]
You can even build your image now on your raspberry pi. But be aware it´s still a (nice working) preview.
Related
I am not sure how to debug container start process.
I created a templated Blazor wasm hosted app (.NET 6) in VS 2022 and added docker support. Docker file configuration is default - I did not change anything in it
I have pushed this image to docker hub.
I have cleared all the images and containers from cache, docker images -a and docker ps -a return no data.
I execute docker pull on both developmen computer (Win11) and ubuntu server.
I run the container on both Win11 and ubuntu: docker run -dit -p 5000:80 username/imagename
On Win11 container is running in the background, status: UP and I can access my app on localhost:5000
However, on ubuntu container runs and exists (status: Exited (0) About 3 secs ago).
docker logs containername returns no data
docker inspect returns in config section: "Architecture": "amd64", "Os": "linux", "Entrypoint": [ "dotnet", "App.Server.dll" ] - so that looks OK
Dockerfile
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["TestApp/Server/TestApp.Server.csproj", "TestApp/Server/"]
COPY ["TestApp/Shared/TestApp.Shared.csproj", "TestApp/Shared/"]
COPY ["TestApp/Client/TestApp.Client.csproj", "TestApp/Client/"]
RUN dotnet restore "TestApp/Server/TestApp.Server.csproj"
COPY . .
WORKDIR "/src/TestApp/Server"
RUN dotnet build "TestApp.Server.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "TestApp.Server.csproj" -c Release -o
/app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "TestApp.Server.dll"]
Any ideas why I have different behavior on ubuntu server, and how can I debug this?
Following this link I build a .Net Core application and was able to run the application in a docker container. My host machine OS is Windows 10, and I now want to try to run the linked application in a Linux container. I have switched to Linux containers with Docker Desktop.
When I'm building the docker image I get this error:
failed to register layer: error creating overlay mount to /var/lib/docker/overlay2/f3e5279484774002c78a8eb66702c9ee7bca7038b59f4eeca7085b88dcbe25d9/merged: too many levels of symbolic links
The Dockerfile I've Used:
FROM mcr.microsoft.com/dotnet/core/runtime:3.1-nanoserver-1903 AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-nanoserver-1903 AS build
WORKDIR /src
COPY ["NetCore.Docker/NetCore.Docker.csproj", "NetCore.Docker/"]
RUN dotnet restore "NetCore.Docker/NetCore.Docker.csproj"
COPY . .
WORKDIR "/src/NetCore.Docker"
RUN dotnet build "NetCore.Docker.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "NetCore.Docker.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "NetCore.Docker.dll"]
Thanks
reason for this is I was using wrong image, had to change the image which support linux containers
I'm running into a seemingly impossible situation: I am building a .Net application with the following Dockerfile:
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019 AS netbuild
WORKDIR /app
COPY . ./
RUN dotnet publish -c Debug -o out
FROM mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019
WORKDIR /app
COPY --from=netbuild /app/MyProject/out .
#Some other things and an entrypoint
And my build command is
docker build -t myapp:test -f Dockerfile-backend-only .
On my local machine this works perfectly fine. However, when I run it on a different machine, which serves as a build agent, dotnet publish decides to put the result of the build into C:\app\out instead of C:\app\MyProject\out.
Now I already read that the behaviour of the -o option for relative paths changed in some releases of the build tools, but this is a Dockerfile, so this shouldn't have any effect. Also both machines are running Win 10 Pro and have up-to-date Docker installations.
I want to run multiple instances of .net core API on windows server 2016 using windows docker container. I am able to create image and container successfully, but on invoking docker start the container are not running Up instead it exited with code (2147516566).
Here is my docker file content which is in published API directory
FROM mcr.microsoft.com/dotnet/core/runtime:2.2-nanoserver-sac2016
COPY / app/
ENTRYPOINT ["dotnet", "app/MyAPI.dll"]
I didn't spend long on it, but I didn't have good luck running binaries I built myself. The docker add in for visual studio always performs the build inside a container. I have adapted to this. Here is an example Dockerfile I have anonymized. Hopefully I didn't break anything:
# Base image for running final product
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-nanoserver-sac2016 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
# build asp.net application
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-nanoserver-sac2016 AS build
WORKDIR /src
COPY ["Test.Docker.Windows/Test.Docker.Windows.csproj", "Test.Docker.Windows/"]
RUN dotnet restore "Test.Docker.Windows/Test.Docker.Windows.csproj"
COPY . .
WORKDIR "/src/Test.Docker.Windows"
RUN dotnet build "Test.Docker.Windows.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "Test.Docker.Windows.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
# startup.bat contains dotnet test.Docker.Windows.dll
CMD ./startup.bat
So I'm not sure what information is required here, but I'm going to try my best, I've built a small website that runs in dotnet-core, more specifically dotnet-core 2.0:<TargetFramework>netcoreapp2.0</TargetFramework>.
I have installed docker on my raspberry pi:
pi#swarm-1:~ $ docker --version
Docker version 18.01.0-ce, build 03596f5
I have also managed to install dot net core 2.0 on there as well through this guide
https://jeremylindsayni.wordpress.com/2017/07/23/running-a-net-core-2-app-on-raspbian-jessie-and-deploying-to-the-pi-with-cake/
pi#swarm-1:~ $ dotnet --info
Microsoft .NET Core Shared Framework Host
Version : 2.0.4
Build : 7f262f453d8c8479b9af91d34c013b3aa05bc1ff`
I have downloaded a docker image onto my pi:
pi#swarm-1:~ $ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
joro550/radiusnet latest d579944265b0 16 hours ago 349MB
When I run the docker run command I do get a id back from docker:
pi#swarm-1:~ $ docker run -d -p 8080:80 joro550/radiusnet
d5c579332abef8cf1938ef7a88aea43e3e84380099e44e2adee7fca196a49de9
but when I list my running containers with ps I get an emty list:
pi#swarm-1:~ $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
pi#swarm-1:~ $
I have tried to run docker ps -a:
The contents of the dockerfile if this is useful for anyone:
FROM microsoft/aspnetcore-build:2.0 AS build-env
WORKDIR /app
# copy csproj and restore as distinct layers
COPY /src ./
RUN dotnet restore
# copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# build runtime image
FROM microsoft/aspnetcore:2.0
WORKDIR /app
COPY --from=build-env /app/src/RadiusNet.Web/out .
ENTRYPOINT ["dotnet", "RadiusNet.Web.dll"]`
Intestingly when I run dotnet *.dll
I get the error message:
pi#swarm-1:~ $ dotnet helloworld.dll
Did you mean to run dotnet SDK commands? Please install dotnet SDK from:
http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
Following the Debian guide for the dotnet-core install give me this:
If there is anything I missed please let me know
After a bit of research and a lot of trial and error I believe it was an issue with my docker file, updated docker file below:
FROM microsoft/aspnetcore-build:2.0 AS build-env
WORKDIR /app
# copy csproj and restore as distinct layers
COPY /src ./
RUN dotnet restore
# copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out -r linux-arm
# build runtime image
FROM microsoft/dotnet:2.0.0-runtime-stretch-arm32v7
WORKDIR /app
COPY --from=build-env /app/src/RadiusNet.Web/out .
ENTRYPOINT ["dotnet", "RadiusNet.Web.dll"]