mviereck / x11docker

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

how to let x11docker run in background #410

Closed showfuture closed 2 years ago

showfuture commented 2 years ago

Hi, I want to run this code in bash : x11docker --gpu --runtime=nvidia --hostdisplay , but it cann't be running in background, how to let it run like this : nohup x11docker --gpu --runtime=nvidia --hostdisplay &;

mviereck commented 2 years ago

I cannot reproduce the issue, it works here. My example:

nohup x11docker --hostdisplay x11docker/check &

Your example does not contain an image name, might be that the issue?


An alternative to run x11docker in background (if using bash) is:

read Xenv < <(x11docker --hostdisplay --showenv x11docker/check)

This has the advantage that the shell stops until the container is up and running.

showfuture commented 2 years ago

Yes! it works!

read Xenv < <(x11docker --hostdisplay --showenv x11docker/check)

my origin code is

sh -i  /keystore/testserver  -o 'StrictHostKeyChecking no' root@unity3d.cnbeijing.yidianshihui.com \
'nohup /usr/bin/x11docker --gpu --runtime=nvidia --hostdisplay --pull=yes --name=$DOCKER_NAME $REGISTRY_PULL_HOST/bigdata/unity3d-job:$BUILD_VERSION >> /extra_work_log/unity3d-job-$BUILD_VERSION.log 2>&1 & '

it didn't work! say image

when i run

ssh -i  /keystore/testserver  -o 'StrictHostKeyChecking no' root@unity3d.cnbeijing.yidianshihui.com                             'read Xenv < <(x11docker --gpu --runtime=nvidia --hostdisplay --pull=yes --name=unity3d-job /bigdata/unity3d-job:20220113-72 >> /extra_work_log/unity3d-job-20220113-72.log 2>&1)

it also didn't work, I think (>> /extra_work_log/unity3d-job-20220113-72.log 2>&1) make it failed! so i run code is

ssh -i  /keystore/testserver  -o 'StrictHostKeyChecking no' root@unity3d.cnbeijing.yidianshihui.com                             'read Xenv < <(x11docker --gpu --runtime=nvidia --hostdisplay --pull=yes --name=unity3d-job /bigdata/unity3d-job:20220113-72)

it works!!

then I have anther question: how to breakdown x11docker with code! like docker stop container

mviereck commented 2 years ago

The message about Vulkan detection and renderers is rather a different thing. You cannot use GPU through SSH.

then I have anther question: how to breakdown x11docker with code! like docker stop container

One possibility: Kill PID 1 of the container. Get it like:

read Containerpid1 < <(x11docker --hostdisplay --showpid1 x11docker/check)
# later:
kill "$Containerpid1"
showfuture commented 2 years ago

I have to do this, but it also works!!

ssh -i  /keystore/testserver  -o 'StrictHostKeyChecking no' root@unity3d.cnbeijing.yidianshihui.com                             'read Xenv < <(x11docker --gpu --runtime=nvidia --hostdisplay --pull=yes --name=unity3d-job /bigdata/unity3d-job:20220113-72)

when I run this:

read Xenv < <(x11docker --gpu --runtime=nvidia --hostdisplay --pull=yes --name=unity3d-job  image-name)

x11docker how to volume image log-file

mviereck commented 2 years ago

If you use read var < <(x11docker ...), please always add one of the --show* options. For Xenv it is --showenv, to get the PID use --showpid1. Otherwise read will get some random output of the container application.

x11docker how to volume image log-file

I don't understand your question. The container output is printed on terminal, right?

showfuture commented 2 years ago

sorry, my question is x11docker run a container, the container have a log file , I want to volume the container inner log file to local file!

mviereck commented 2 years ago

Oh, ok. Is the log file stored in HOME? Than use x11docker option --home. It shares a folder on host as HOME in container, you should find the log there. Have a look at folder ~/x11docker on host, a subfolder with the image name contains HOME of container.

showfuture commented 2 years ago

its all works! thanks very much

mviereck commented 2 years ago

You're welcome. :-)