failed to load /usr/bin/dotnet: exec format error - c#

I'm trying to use DigitalOcean to host a C# docker container on docker hub (With the Apps platform)
[2021-12-08 23:24:04] starting container: starting non-root container [dotnet Alace.cs.dll]: creating process: failed to load /usr/bin/dotnet: exec format error
The container runs perfectly fine on my computer.

Your image is built for an Arm processor and the DigitalOcean machine is probably an amd64 machine.
You can try building for amd64 with the buildx command. Something like
docker buildx build --platform linux/amd64 -t alyxw/alace-cs:amd64 .

Related

How to configure proxy for NuGet while using Docker?

I am using dotnet:2.1-sdk as a package while building docker image.
The RUN dotnet restore command is failing with below errors:
**error : Unable to load the service index for source https://api.nuget.org/v3/index.json.**
**error : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond**
**The command 'cmd /S /C dotnet restore' returned a non-zero code: 1**
Its an issue with proxy because if I bypass the corporate network and connect to my personal network, it works.
I also tried placing the NuGet.Config file the source directory and also tried to copy it to WORKDIR. Nothing worked.
Please let me know the procedure of setting the "Proxy" for making dotnet restore work in the docker environment.
Thanks.
Check my answer here.
Basically, you should instruct the docker build environment to use the proxy by adding build arguments like:
docker build --build-arg HTTP_PROXY=<proxy URL> --build-arg HTTPS_PROXY=<proxy URL> -t <application name>

I failed at :docker build -t my_aspnetcore .the brief error info is :invalid reference format

I want to create a docker image for my Asp.net Core application. The environment is CentOS7.5, and dotnet-sdk-2.1.500. Here is the full error message when I enter the command.
docker build -t wechat .:
Sending build context to Docker daemon 1.547 MB
Step 1/17 : FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
Error parsing reference: "microsoft/dotnet:2.1-aspnetcore-runtime AS base" is not a valid repository/tag: invalid reference format
Sending build context to Docker daemon 1.547 MB
Step 1/17 : FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
Error parsing reference: "microsoft/dotnet:2.1-aspnetcore-runtime AS base" is not a valid repository/tag: invalid reference format
I wonder is there any setup I did wrong? How can I get through it?
For invalid reference format, it is usually caused by the wrong docker version.
For FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base, it uses the docker new feature named multi-stage builds which requires Docker 17.05 or higher.
Try to follow Get Docker CE for CentOS to reinstall or upgrade your docker ce.

Nuget Restore failure in Azure Functions on a docker container-

I am having problems with my docker build script for a basic Azure Function. I have been following this blog post:
https://medium.com/#adrianromanin/azure-functions-on-a-docker-container-7b00d2c36eb2
At the point of the nuget restore I get the following errors:
Restoring packages for
C:\src\dotnet-function-app\functionsanddockerdemo.csproj... C:\Program
Files\dotnet\sdk\2.1.403\NuGet.targets(114,5): error : Unable to load
the service index for source https://api.nuget.org/v3/index.json.
[C:\src\dotnet-function-app\functionsanddockerdemo.csproj] C:\Program
Files\dotnet\sdk\2.1.403\NuGet.targets(114,5): error : A connection
attempt failed because the connected party did not properly respond
after a period of time, or established connection failed because
connected host has failed to respond
[C:\src\dotnet-function-app\functionsanddockerdemo.csproj] The command
'cmd /S /C dotnet restore
src/dotnet-function-app/functionsanddockerdemo.csproj -s
https://api.nuget.org/v3/index.json' returned a non-zero code: 1
My docker build script:
FROM microsoft/dotnet:2.1-sdk AS installer-env
COPY . /src/dotnet-function-app
RUN mkdir "home/site/wwwroot/"
RUN dir "C:/src/dotnet-function-app"
RUN dotnet publish src/dotnet-function-app/functionsanddockerdemo.csproj --output /home/site/wwwroot
I've tried explicitly specifiying package restore via both of these commands:
RUN dotnet restore src/dotnet-function-app/functionsanddockerdemo.csproj -s https://api.nuget.org/v#3/index.json
RUN dotnet restore src/dotnet-function-app/functionsanddockerdemo.csproj --verbosity diag
However they both give the same result. I initially thought maybe my container didn't have any network connectivity, however I have connectivty confirming via:
RUN ping www.google.co.uk
My docker info:
Server Version: 18.06.1-ce
Storage Driver: windowsfilter
Windows:
Logging Driver: json-file
Plugins:
Volume: local
Network: ics l2bridge l2tunnel nat null overlay transparent
Log: awslogs etwlogs fluentd gelf json-file logentries splunk syslog
Swarm: inactive
Default Isolation: hyperv
Kernel Version: 10.0 17134 (17134.1.amd64fre.rs4_release.180410-1804)
Operating System: Windows 10 Pro Version 1803 (OS Build 17134.285)
I am sure I hav missed something basic here!

Can't build ASP.Net container

Windows 10 version 1607
Docker for Windows: Version 17.06.1-ce-win24 (13025)
I'm trying to build a asp .net 4.6 container using the provided docs and its not working.
I'm using this provided dockerfile. I copied it to the root of one of my asp .net solutions.
And the I ran this command:
$ docker build -t aspnet-site --build-arg site_root=/
This is the output
PS> docker build -t aspnet-site . --build-arg 'site_root=/'
Sending build context to Docker daemon 326.1MB
Step 1/6 : FROM microsoft/dotnet-framework:4.6.2
4.6.2: Pulling from microsoft/dotnet-framework
3889bb8d808b: Pull complete
9f5eeabe6154: Pull complete
Digest: sha256:c281f2c09c9446f1896806933013a350f19db8f5a009e633ebd9701c470de35b
Status: Downloaded newer image for microsoft/dotnet-framework:4.6.2
---> be84290c2315
Step 2/6 : SHELL powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';
---> Running in 1fd036b1b56e
---> 413164f1a97c
Removing intermediate container 1fd036b1b56e
Step 3/6 : RUN Add-WindowsFeature Web-Server; Add-WindowsFeature NET-Framework-45-ASPNET; Add-WindowsFeature Web-Asp-Net45; Remove-Item -Recurse C:\inetpub\wwwroot\*
---> Running in 4b0e5751281b
Success Restart Needed Exit Code Feature Result
------- -------------- --------- --------------
True No Success {Common HTTP Features, Default Documen...
True No Success {ASP.NET 4.6}
True No Success {Application Development, ASP.NET 4.6,...
---> 9afab6bfa836
Removing intermediate container 4b0e5751281b
Step 4/6 : ADD ServiceMonitor.exe /
ADD failed: GetFileAttributesEx \\?\C:\WINDOWS\TEMP\docker-builder455754487\ServiceMonitor.exe: The system cannot find the file specified.
So it does say this in the docs (so I tried commenting out the servicemonitor stuff and it worked):
There is no need to specify an ENTRYPOINT in your Dockerfile since the
microsoft/aspnet base image already includes an entrypoint application
that monitors the status of the IIS World Wide Web Publishing Service
(W3SVC).
Try with this dockerfile instead. It will use the aspnet image:
FROM microsoft/aspnet
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
EXPOSE 80
RUN Remove-WebSite -Name 'Default Web Site'
RUN New-Website -Name 'YourSiteName' -Port 80 -PhysicalPath 'C:\YourFolderName' -ApplicationPool '.NET v4.5'
ADD "LocalFolderPath" /YourFolderName

No executable found matching command "dotnet-/../.dll" when running dotnet core docker image in Azure Web App on Linux

1. Background
I'm currently working on the following build/deployment pipeline:
Github (https://github.com/devedse/DeveMazeGeneratorCore)
Travis Build (https://travis-ci.org/devedse/DeveMazeGeneratorCore/jobs/196910720)
dotnet restore
dotnet build
dotnet publish
docker create image
docker publish image to hub
Docker image hub (https://hub.docker.com/r/devedse/devemazegeneratorcore/)
Use Azure Web App on Linux to execute deployment (http://devemazegeneratorcoredocker.azurewebsites.net/api/mazes/MazePath/512/512)
.
2. Problem
Whenever I push something to the Github repository, a build is kicked off and step 1-3 are being executed correctly.
However, the website on Azure is unreachable.
I used SCM to browse to the debug console (https://devemazegeneratorcoredocker.scm.azurewebsites.net/DebugConsole/Default.cshtml (for future reference)) and executed the following commands to find the log files that were generated by Docker:
and then used the following commands to read them:
cat docker_128_err.log
cat docker_128_out.log
The out log showed the following results (which seem correct):
Login Succeeded
latest: Pulling from devedse/devemazegeneratorcore
5040bd298390: Already exists
fce5728aad85: Already exists
76610ec20bf5: Already exists
51ee4768b31d: Already exists
4dc55ff439a1: Already exists
9cb727c7d7a0: Already exists
2bea08464ad0: Pulling fs layer
2bea08464ad0: Verifying Checksum
2bea08464ad0: Download complete
2bea08464ad0: Pull complete
Digest: sha256:647f3db3daa3330b7eb109a1c604e5bd403c2c7089b3c18c5e9249a9805d3a4d
Status: Downloaded newer image for devedse/devemazegeneratorcore:latest
Login Succeeded
latest: Pulling from devedse/devemazegeneratorcore
Digest: sha256:647f3db3daa3330b7eb109a1c604e5bd403c2c7089b3c18c5e9249a9805d3a4d
Status: Image is up to date for devedse/devemazegeneratorcore:latest
The error log however, shows the following errors:
2017-01-31T13:11:46.757760723Z No executable found matching command "dotnet-/home/DeveMazeGeneratorCoreWebPublish/DeveMazeGeneratorWeb.dll"
The strange thing is, is that whenever I run the image locally, it all works fine:
docker run -it --rm -p 0.0.0.0:5001:80 devedse/devemazegeneratorcore:latest
Somehow there seems to be a difference in running a Docker image on a Linux machine in Azure, compared to my local Docker installation which runs the Docker images on the default VM that's being installed when you install Docker for Windows.
3. Configuration files used:
.travis.yml: (https://github.com/devedse/DeveMazeGeneratorCore/blob/master/.travis.yml)
Dockerfile: (https://github.com/devedse/DeveMazeGeneratorCore/blob/master/Scripts/Docker/Dockerfile)
4. Summary
So summarizing, it seems that running Docker on Azure is being executed in a different manner then when doing this locally. Does anyone have an idea on what this could be/how to solve it?
Again, (just for easy reference), the error:
2017-01-31T13:11:46.757760723Z No executable found matching command "dotnet-/home/DeveMazeGeneratorCoreWebPublish/DeveMazeGeneratorWeb.dll"
Modify your image to put your application bits somewhere other than /home.
/home is where Azure App Service on Linux bind-mounts the persistent site volume, which is a disk that is shared across instances and is persisted between restarts.
You don't have to use it (you may not have any use for it when running your own image), but anything in your image's /home will disappear at runtime.

Categories

Resources