WebKitWebProcess / Gdk-Error when trying to run a Tauri app in a container via x11 connection - docker

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.

Related

I can't initialize docker on Windows 10

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?

Pycharm attach to process inside a container causes accept timeout

I am using pycharm professional 2021.3.1 and ubuntu 18.04
I can attach to any process running directly on the host
However if the process is running inside a container (no matter what host privileges' I gave it)
I cannot attach. I get the following error
"Connection to python debugger failed Accept timeout'
I Tried on another computer and got the same results
Is this a known issue? Are there any work arounds? Except for using remote debugger (which requires adding extra code to the production code)
I found a way, it is not documented (as far as I can tell) but since it is for debugging only I will continue with it
Pycharm Professional set the IDE like you would for remote debug server
https://www.jetbrains.com/help/pycharm/remote-debugging-with-product.html#remote-debug-config
In the docker file of the containers that you wish to debug always install:
gdb
pydevd-pycharm
After the container and the process is up go into the container and run
"python3 /usr/local/pydevd_attach_to_process/attach_pydevd.py --port port_set_in_pycharm --pid pid_of_process_to_debug_in_container_id --host ip_of_the_host_running_the_pycharm"
the following is the same command pycharm uses when you do attach to process
now you can put breakpoints and debug normally
Advantage of this solution in contrast to remote debug defined in the pycharm documentation is that we do not have to add code to the production code

Suppressing display in docker

I have a docker image with a medical data analysis app installed in it. The app works from both gui and console. Normally, in my linux, I run the app from the terminal as
./dsi_studio --action=trk ...
and it works quite smoothly. If you click on this app, it'll try to open a GUI. While I'm trying to use this inside the docker image, it tries to connect to the display in any case (even if I run as shown in the terminal). And, of course, since I didn't do any setup for showing GUI from docker, I get the following error, stating that it couldn't find a display to connect.
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
I don't know why the app is trying to open a display while running in terminal, because it doesn't open a GUI in my linux. I just want to suppress this warning somehow, as if there is a fake display. I don't want to connect my display to docker image, because this image is going to run in batch in an HPC.
So, How can I do this?
You should probably export the DISPLAY environment variable to point to your linux terminal.
Just to test, run
xhost +
in your linux terminal and add
-e DISPLAY=:0.0
to your docker command line

Running gdb in Debian docker image results

I have some trouble when running gdb in a docker image and I am not sure what is causing the problems since I am a complete newbie when it comes to gdb and docker.
Background
I am trying to write a c++ program for the Lego EV3 which runs on ev3dev. In order to compile it, I have set up docker with the ev3dev image on my Windows machine and am able to successfully build inside that image, transfer the binary to the EV3 and execute it there. This all works well until I need to start (remote) debugging. My plan is to start a gdbserver on the EV3 with the program and the open a gdb session inside the docker container in my Windows machine and connect to the EV3 gdbserver. After I have fixed the first error when remote debugging - I needed to use gdb-multiarch on my Windows machine - I have encountered more problems which I don't really find a solution too.
Problem
When running gdb directly on my Windows machine inside the docker container (or when connecting to the gdbserver from docker using gdb-multiarch) I always get the following output after starting the program with run:
(gdb) run
Starting program: /src/ev3/build/src/EV3_main
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
Warning:
Cannot insert breakpoint -1.
Cannot access memory at address 0x4f58
and when using next or step I get:
(gdb) next
Cannot find bounds of current function
Since I couldn't really find any solution online, I would really appreciate any help!
Thanks in advance!
I always get the following output after starting the program with run
This error usually means that the dynamic loader in your docker container has been fully stripped. It's a packaging mistake by the creator of that container.
If you are not using dlopen(), this isn't a big problem.
(gdb) next
Don't do that: you are not stopped in a location where GDB knows where the next line is. Do continue instead.

Docker: Running Windows Console application - Failed to create system events window thread

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.

Resources