Docker Inside Docker Variation - c#

i have a c# console Application which generates Frontend and Backend technology working API's code . The technologies are provided by command line. Now i have to do docker build on this c# code and then do docker run, so when it starts executing, my c# code which generates frontend and backend does docker build and docker push from inside my c# console app which is currently executed by docker run.
so my console App(build and run in docker and then push)->Frontend(need to build and push while console app docker container is running) same for backend. So is there anyway by which i can access docker commands like build and run when docker container is running?
First i tried to install docker inside container from c# itself and do dockerd but it gave some errors:
ERRO[2023-02-01T10:22:51.825248406Z] failed to change OOM score to
-500 error="write /proc/1596/oom_score_adj: permission denied" WARN[2023-02-01T10:22:51.825968126Z] failed to load plugin
io.containerd.snapshotter.v1.btrfs error="path
/var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.btrfs
must be a btrfs filesystem to be used with the btrfs snapshotter"
WARN[2023-02-01T10:22:51.826131208Z] failed to load plugin
io.containerd.snapshotter.v1.aufs error="modprobe aufs failed: "":
exec: "modprobe": executable file not found in $PATH"
WARN[2023-02-01T10:22:51.826696261Z] failed to load plugin
io.containerd.snapshotter.v1.zfs error="path
/var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.zfs
must be a zfs filesystem to be used with the zfs snapshotter"
WARN[2023-02-01T10:22:51.826774710Z] could not use snapshotter btrfs
in metadata plugin error="path
/var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.btrfs
must be a btrfs filesystem to be used with the btrfs snapshotter"
WARN[2023-02-01T10:22:51.826812801Z] could not use snapshotter aufs in
metadata plugin error="modprobe aufs failed: "": exec:
"modprobe": executable file not found in $PATH"
WARN[2023-02-01T10:22:51.826830379Z] could not use snapshotter zfs in
metadata plugin error="path
/var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.zfs
must be a zfs filesystem to be used with the zfs snapshotter"
ERRO[2023-02-01T10:22:51.850428838Z] 'overlay2' is not supported over
overlayfs storage-driver=overlay2
ERRO[2023-02-01T10:22:51.850686363Z] AUFS was not found in
/proc/filesystems storage-driver=aufs
ERRO[2023-02-01T10:22:51.850761639Z] 'overlay' is not supported over
overlayfs storage-driver=overlay
WARN[2023-02-01T10:22:51.884958624Z] Unable to setup quota: operation
not permitted WARN[2023-02-01T10:22:51.934196670Z] Your kernel does
not support cgroup blkio weight WARN[2023-02-01T10:22:51.934277367Z]
Your kernel does not support cgroup blkio weight_device
WARN[2023-02-01T10:22:51.934292526Z] Your kernel does not support
cgroup blkio throttle.read_bps_device
WARN[2023-02-01T10:22:51.934304427Z] Your kernel does not support
cgroup blkio throttle.write_bps_device
WARN[2023-02-01T10:22:51.934314689Z] Your kernel does not support
cgroup blkio throttle.read_iops_device
WARN[2023-02-01T10:22:51.934345730Z] Your kernel does not support
cgroup blkio throttle.write_iops_device
WARN[2023-02-01T10:22:51.935613743Z] Running modprobe nf_nat failed
with message: , error: exec: "modprobe": executable file not found in $PATH WARN[2023-02-01T10:22:51.935667152Z] Running modprobe xt_conntrack failed with message: , error: exec: "modprobe":
executable file not found in $PATH Error starting daemon: Error
initializing network controller: error obtaining controller instance:
failed to create NAT chain DOCKER: iptables failed: iptables -t nat -N
DOCKER: iptables: Permission denied (you must be root).
How to fix this?

Related

failed to load /usr/bin/dotnet: exec format error

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 .

Error : Unable to load DLL 'libgmp-10.dll' when testing azure function c# .net 5.0

I published my c# .NET 5.0 code to azure functions (windows) and im getting this weird error message:
2021-06-21T01:56:53.465 [Error] Executed 'Function1' (Failed, Id=fdefdbba-49a7-44ad-8082-841d2941d90b, Duration=169ms)Unable to load DLL 'libgmp-10.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)
I tried to see the \wwwroot files on the azure functions console but then i get this error:
3 [main] ls (8392) C:\Program Files\Git\usr\bin\ls.exe: *** fatal error - Couldn't set directory to \\?\PIPE\ temporarily.
Any hints?
It seems that the deployment is not done correctly.
Libgmp-10.dll a DLL (Dynamic Link Library) file which is referred to
essential system files of the Windows OS. It usually contains a set of
procedures and driver functions, which may be applied by Windows.
Please delete the Azure Function and, re-create and deploy a fresh code using Develop and publish .NET 5 functions using Azure Functions OR if you are using ADO, Setting up a CI/CD pipeline for Azure Functions.
Let me know if you have any follow up questions.

Is it possible to run Kinect V2 inside a Docker container?

I'm exploring the feasibility of running a C# Kinect Visual Gesture Program (something like Continuous Gesture Basics project https://github.com/angelaHillier/ContinuousGestureBasics-WPF) inside of a Docker for Windows container.
Is this even theoretically possible (run C# Kinect in a Docker for Windows container?)
If the answer to 1 is yes, here are some extra details:
I'm using the microsoft/dotnet-framework:4.7 image as a basis and my initial Dockerfile looks like this:
FROM microsoft/dotnet-framework:4.7
ADD . /home/gesture
WORKDIR /home/gesture
Build the image:
$ docker build -t kinect .
Turn on container:
$ docker run -dit --name kinectContainer kinect
Attach to a powershell session to monkey around:
$ docker exec -it kinectContainer powershell
When I attempt to run my gesture application from the Docker container I get the following error (which is expected since no Kinect SDK was installed in the container):
Unhandled Exception: System.BadImageFormatException: Could not load file or assembly 'Microsoft.Kinect, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependenc
ies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058) ---> System.BadImageFormatExcep
tion: Cannot load a reference assembly for execution. erable program. Check the spelling of the name, or if a path was included, verify that the path
--- End of inner exception stack trace ---
at GestureDetector.GestureDetectorApp..ctor()
At this point, the big question is how to install the Kinect v2 SDK [KinectSDK-v2.0_1409-Setup.exe] or the Kinect v2 runtime [KinectRuntime-v2.0_1409-Setup.exe] in the container.
The installers have a EULA and according to some clever University of Wisconsin folks, there is a technique to to extract installers using Wix's dark.exe decompiler(https://social.msdn.microsoft.com/Forums/en-US/a5b04520-e437-48e3-ba22-e2cdb46b4d62/silent-install-installation-instructions?forum=kinectsdk)
ex.
$ & 'C:\Program Files (x86)\WiX Toolset v3.11\bin\dark.exe' C:\installerwork\KinectRuntime-v2.0_1409-Setup.exe -x c:\installerwork\kinect_sdk_installersfiles
The issue I ran into when I got to the underlying msi files is there is no option to run them silently using msiexec.
I've figured out that the runtime installer (Runtime installer (KinectRuntime-x64.msi) extracted from the Kinect v2 SDK) makes at least the following changes in the filesystem:
Creates a folder "Kinect" in C:\Windows\System32 and adds 3 files to System 32:
k4wcll.dll
kinect20.dll
microsoft._kinect.dll
The last three files in System32 should be the 64-bit versions (the installer appears to have x86 and x64 versions of those 3)
Replicating those changes by hand does not lead to success on the host machine let alone in the container.
It's currently unclear what other registry/system changes are occurring with the installer (and whether or not that would get us over the goal line in the Docker container)
Any ideas about how to proceed from here?
In short no. docker on windows does not have the ability to hardware tunnel/map. on Linux, it does via the --device= option
As #VonC has stated you will need to use a Windows VM this could be Hyper-V or you can use Virtual Box then you can provide the Kinect Hardware via the Tunneling method (add/connect device), without this there would be no way for your container be that VM or not to access the hardware of the host machine with windows.
Another approach would be to try and install Kinetic in a Windows server VM, and detect the exact changes brought by said installation.
See for instance "How can I find out what modifications a program’s installer makes?" and a tool like ZSoft Uninstaller 2.5.
Once you have determined exactly what files/registry/variables are impacted by the installation process, you can replicate that in a Dockerfile.

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.

Sonar Scanner for MSBuild on linux [duplicate]

When I run sonar-runner for an analysis my simple C# project the analysis terminate on error on SonarLint.Runner.exe of permission denied:
ERROR: Error during SonarQube Scanner execution
ERROR: java.io.IOException: Cannot run program "/opt/sonarqube-5.4/projects/ArturiCSharpSort/.sonar/SonarLint.Runner/SonarLint.Runner.exe": error=13, Permission denied
ERROR: Caused by: Cannot run program "/opt/sonarqube-5.4/projects/ArturiCSharpSort/.sonar/SonarLint.Runner/SonarLint.Runner.exe": error=13, Permission denied
ERROR: Caused by: error=13, Permission denied
Effectively
-rw-r--r-- 1 root root 19456 Apr 5 11:14 .sonar/Lint.Runner/SonarLint.Runner.exe
This following is my sonar-project.properties:
# Root project information
sonar.projectKey=ArturiCSharpSort
sonar.projectName=ArturiCSharpSort
sonar.projectVersion=1.0
# Some properties that will be inherited by the modules
sonar.sources=.
#List of the module identifiers
#sonar.modules=
# Properties can obviously be overriden for
# each module - just prefix them with the module ID
#module1.sonar.projectName=
#module2.sonar.projectName=
I try to act a chmod on SonarLint.Runner.exe but it is rebuil at every analysis.
How can I run analysis on C# project?
Analysis of C# projects must be done on a Windows environment. Here it's failing because the project is analysed on Linux.
The thing is that SonarQube C# Plugin really is targeted to the Windows .NET ecosystem, which is where you'd anyhow build/maintain .NET projects. It must be used with the SonarQube Scanner for MSBuild, which requires MSBuild 14.0.

Categories

Resources