mviereck / x11docker

Run GUI applications and desktops in docker and podman containers. Focus on security.
MIT License
5.62k stars 378 forks source link

sometimes need delay before $Pid1pid is valid #133

Closed gidfiddle closed 5 years ago

gidfiddle commented 5 years ago

x11docker --version: 5.4.4

On a rather slow Ubuntu 18.04 machine, the command

x11docker --nxagent ubuntu:bionic

always fails with a "Container startup seems to have failed." error, despite (usually) working well on a faster Fedora 29 machine. I traced the problem to the following statement in the x11docker script:

Pid1pid=$($Dockerexe inspect --format '{{.State.Pid}}' $Containername 2>>$Containerlogfile | rmcr)

sets Pid1pid to zero. I succeeded in working around this problem by putting this line in a loop like another one in the script:

for ((Count=1 ; Count<=20 ; Count++)); do
    [line above]
    if test x$Pid1pid != x && test $Pid1pid -ne 0; then break; fi
    sleep 0.2
done

(The first test is needed because Fedora sometimes sets Pid1pid to a blank.) One pass through the loop usually suffices to get a valid Pid1pid.

I cannot explain why a delay is necessary here even after the container has been determined to be "ready" because the test

$Dockerexe exec $Containername sh -c :

has succeeded.

Could you please look into this issue and make an appropriate correction?

Thanks for a great piece of software.

mviereck commented 5 years ago

Thank you for reporting!

I cannot explain why a delay is necessary here even after the container has been determined to be "ready" because the test $Dockerexe exec $Containername sh -c : has succeeded.

That is odd, indeed. I have made a commit with a repeated check like in your proposal, it should work now. Please try out.

Thanks for a great piece of software.

:-)