I am trying to run a windows console application (.net core) in a container. It is working fine on host but as soon as I run the docker container, it throws this error:
The type initializer for 'MyApp.Utility.SystemEventsHandler' threw an exception.
---> System.Runtime.InteropServices.ExternalException (0x80004005): Failed to create system events window thread.
at Microsoft.Win32.SystemEvents.EnsureSystemEvents(Boolean requireHandle)
at Microsoft.Win32.SystemEvents.add_SessionEnding(SessionEndingEventHandler value)
Docker File
# getting base image
FROM mcr.microsoft.com/dotnet/runtime:3.1
# copy files
COPY app/ app/
# set working directory
WORKDIR app
# entry point
#ENTRYPOINT ["dotnet","MyApp.dll"]
Do I need to install something else too in the container ?
The problem is not that you are running the console app on a windows OS host with docker. The problem is that you are running a linux container (very slim version of a linux OS) and then trying to access windows specific APIs.
As the error states Failed to create system events window thread. at Microsoft.Win32.SystemEvents...
That is why the application is working just fine when you debug it on your windows OS host, but not in a linux container. You will get the same effect if you deploy it to a regular linux host or trying to run it in WSL for example.
One thing that might work is switching to a windows container, but I don't know how your code looks. To switch to windows container, I think you simply right click the system tray icon for docker desktop and swap. But I've never used windows containers, so I would not know.
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/docker/building-net-docker-images?view=aspnetcore-5.0#run-in-a-windows-container
PS I hope you are not trying to run a GUI application in docker, that is not supported.
Related
I'm trying to display a basic Tauri app GUI running in a Docker container but connected to the host's X11 server through a unix socket. But I get the following warning and error when running npm run tauri dev:
(WebKitWebProcess:6009): Gdk-ERROR **: 00:17:37.147: The program 'WebKitWebProcess' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadValue (integer parameter out of range for operation)'.
(Details: serial 258 error_code 2 request_code 152 (GLX) minor_code 34)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the GDK_SYNCHRONIZE environment
variable to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
I get opened a GUI window on the host but it's blank (but should contain some text / HTML markup).
As I am able to get Firefox and Gedit running from within the container but not the gnome-terminal, I think it's some permissions issue or there is some missing package to get the Webkit based GUI window connecting to my host's X server.
$DISPLAY and /tmp/.X11-unix are set properly. On the host I set xhost +
The container is running as node user. Cargo is installed in /home/node/.cargo/bin. /home/node is owned by root:node with 775 permissions on folders and 664 on files (+x on executable scripts).
I'm just getting started with Rust and Tauri and also not a big expert on X server and Docker networking.
Any ideas how to get it work?
I ended up using Qemu + Virt-Manager instead of docker. For the starters I've used an Ubuntu template as the clipboard sharing works out of the box with my host running on Ubuntu as well. Sound sharing and video playback works out of the box, too. And if I should get in the situation where I would need a separate VM for each app, then I would use my minimalist Arch template to spin up the VM's - the size should be pretty close to that of a docker container.
Edit:
LXC/LXD and Podman might be even better alternatives, I have been told.
My PHP project is stored in WSL, accessed by PhpStorm installed on Windows and running with Docker Desktop installed on Windows.
The Project itself is totally fine, but running Tests is not possible because PhpStorm cannot find the vendor autoload or phpunit.phar in Test Framework configuration.
Setup:
Windows 10 with WSL2 Ubuntu 20.04 LTS
PhpStorm on Windows
Docker Desktop on Windows, Docker Compose files in WSL
Code in home folder in WSL (see following screens)
I read in some older threads that Docker Compose v2 needs to be enabled in Docker Desktop. It is:
Docker is configured inside of PhpStorm and shows that the connection is successful (I know that works because things like Xdebug is working without any issues):
Notice that I configured a path mapping here for the project root.
in WSL: \\wsl$\Ubuntu\home\USERNAME\workspace\PROJECTNAME-web-docker
in Docker: /var/www/PROJECTNAME-web
I can see that those paths are correct by either logging into the Docker container or by checking the Service Tab of PhpStorm and inspecting files:
This is my CLI Interpreter using the docker-compose configuration:
It does not matter if I use the existing container or if it should be starting a new one
PHP Version is always detected
And finally the error inside of Test Framework:
Here I tried different things:
use composer autoloader or phpunit.phar
it doesn't matter if I use a full path /var/www... or just vendor/...
tried different path mappings here
clicking on refresh shows this error in a small popup
Cannot parse PHPUnit version output: Could not open input file: /var/www/PROJECTNAME-web/SUBTOPIC/vendor/phpunit/phpunit/phpunit
autoload.php is definitely available and correct, phpunit is installed and available.
Maybe someone has a hint what is missing or wrong? Thanks!
EDIT:
How do I know that autoload is available or path mapping is correct?
I have Xdebug configured and running. When Xdebug stops in my code, I know that the path mapping is correct. The output of Debug -> Console for example shows stuff like this:
PHP Deprecated: YAML mapping driver is deprecated and will be removed in Doctrine ORM 3.0, please migrate to annotation or XML driver. in /var/www/PROJECTNAME-web/SUBTOPIC/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php on line 62
so I know the path mapping for xdebug works, but seems like Test Framework config does not like it.
I'm prototyping various deployment scenarios for my future delphi web projects. And as I'm going to build the nextgen killer app (...) , I investigated cloud deployment of a docker container for my backend API datasnap server.
As I was new to docker in general and relatively unfamiliar with linux, it was not straightforward.
But I managed to build an delphi 11 alexandria compatible PAServer image and deploy simple apps to my local docker desktop environment ( the radstudio/paserver docker hub images today are unfortunately 10.4.x only versions so no click and run possible...).
However, when deploying a default delphi datasnap webbroker server ( as console application ), the program returns to it's command line and waits for a 'start' instruction.
Sofar, I did't succeed in getting access to that program commandline interactively inside the docker CLI to enter that 'start' instruction ( or get access to the PAServer commandline to e.g. trigger a verbose session for the same matter ).
Yes, I can start the server by default and it 'fixes' the problem but sooner or later I will need this to be available ?
I tried one ( general ) suggestion ( get-apt install reptyr / reptyr PID ) to get access to running processes but it returns with errors and since I'm really newbie on linux/Docker I have no further ideas.
( FYI Deploying to windows, simply opens a command line window that stays available to type in )
# reptyr 83
[-] Timed out waiting for child stop.
Unable to attach to pid 83: Operation not permitted
#
( and an exception is raised in the IDE session 'Project raised exception class Stopped(user)(18)', but the session can be continued )
Ok, so if you start the docker container in interactive mode, the docker host commandline will convert into the container commandline, attached to the 'main' process with PID 1 ( I guess ).
docker run -it -p 8082:8082 -p 64211:64211 -p 80:80 mypaserverimage
connected to the PAServer command line.
But still it remains how to connect to the commandline of the subsequent PAServer deployed console application.
( can't seem to run the container that way from the docker desktop GUI. Need to run from docker host command line )
I installed docker version 20.10.11 on my Windows 10 home with build 19042, the installation was successful, but when running docker, the daemon was not started, so I manually installed wsl2 using this tutorial.
https://nlearn.microsoft.com/en-us/windows/wsl/install
Now when executing any docker command via cli, it shows this message
"Server:
ERROR: error during connect: In the default daemon configuration on Windows, the docker
client must be run with elevated privileges to connect.: Get
"http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/info": open //./pipe/docker_engine: The
system cannot find the specified file.
errors pretty printing info"
I've followed all the tutorials from this link
Docker cannot start on Windows, none of them worked.
When I open the Docker Desktop dashboard, it shows the message docker starting engineer, or something like that, it keeps initializing, but it never finishes initializing.
Virtualization is turned on, when I open processes I notice that docker.service is running and a process called Vmmem, when I look at all the services even the ones that are not running. There's only one, which is the Docker Desktop referring to the docker
Ps: I don't know other programs may be interfering with it, I have an oracle 18cxe database running on my machine, I don't know it's interfering with a network connection or something.
I would like to know how I can get an accurate log, to know what the problem really is, how do I trace this error?
I am a developer who is using Ubuntu 20.04 LTS regularly for my development. I never install any packages like, node, PHP, python in the OS and make use of docker for the purpose. VS Code is the editor I use, and the extension of the remote container will help me to develop & debug inside the docker container.
Right now, I am in the process of moving the development to a windows environment and I wanted to follow a similar workflow there too. Unfortunately, I am facing few issues like "file changes are not getting detected" (when npm serve in angular and react projects).
https://github.com/microsoft/WSL/issues/4739
https://www.reddit.com/r/bashonubuntuonwindows/comments/c48yej/wsl_2_react_not_reloading_with_file_changes/
I have tried different methods to solve the issue like
use wsl2 and then docker inside that and then serve from the container
use just docker and serve the code from inside the container
Regardless of the methods, the file changes are not getting detected inside the docker.
Trust me I have gone through many bizarre words like inotify, increasing the watchers, etc... Nothing helped.
Is there a developer out there following a similar practice in a Windows environment? (docker + windows)
Any help is highly appreciated.
I suggest moving the files to the wsl2 file system and not the windows.
Wsl2 'sees' the windows file system from inside a mount image /mnt/c .
Move out of it, like at ~ (cd ~) and i think your files will be normally watched .