mviereck / x11docker

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

exit code of docker container is not returned by x11docker, always returns exit 0 #383

Closed philippthiele closed 3 years ago

philippthiele commented 3 years ago

I noticed, that the exit code of the docker container is not returned by x11docker. The docker container has a script as entrypoint, that for testing only contains

exit 1

Here is the verbose log of x11docker, notice the "exit 0" that is logged at the end:

DEBUGNOTE[19:13:56,698]: Running containerrc: Unprivileged user commands in container
x11docker[19:13:56,714]: containerrc: Container system:
NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

DEBUGNOTE[19:13:56,718]: containerrc: HOME is not empty. Not copying from /etc/skel
x11docker[19:13:56,732]: Container environment:
DISPLAY=:0
DRONE_COMMIT=localexecution
DRONE_STAGE_NAME=test
HOME=/home/agent47
HOSTNAME=bba4e47cf3c5
OLDPWD=/home/agent47
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/test
TERM=xterm
USER=agent47
XDG_RUNTIME_DIR=/tmp/XDG_RUNTIME_DIR
XDG_SESSION_TYPE=x11
container=docker

DEBUGNOTE[19:13:56,738]: cmdrc: Running container command:
  /test/executeTests.sh

DEBUGNOTE[19:13:57,123]: watchpidlist(): Container x11docker_X0_testexecuternvidiacuda_80428067750 has terminated
DEBUGNOTE[19:13:57,124]: time to say goodbye (watchpidlist x11docker_X0_testexecuternvidiacuda_80428067750)
DEBUGNOTE[19:13:57,126]: time to say goodbye (watchpidlist)
DEBUGNOTE[19:13:57,126]: time to say goodbye (main)
DEBUGNOTE[19:13:57,128]: Terminating x11docker.
DEBUGNOTE[19:13:57,129]: time to say goodbye (finish)
DEBUGNOTE[19:13:57,136]: finish(): Checking pid 15560 (dockerstopshell): 15560 pts/1    00:00:00 bash
DEBUGNOTE[19:13:57,143]: finish(): Checking pid 13388 (containershell): (already gone)
DEBUGNOTE[19:13:57,149]: finish(): Checking pid 12782 (watchmessagefifo): 12782 pts/1    00:00:00 bash
DEBUGNOTE[19:13:57,155]: finish(): Checking pid 12769 (watchpidlist): (already gone)
DEBUGNOTE[19:13:57,219]: Removing container x11docker_X0_testexecuternvidiacuda_80428067750
    x11docker_X0_testexecuternvidiacuda_80428067750
DEBUGNOTE[19:13:58,233]: termpid(): Terminating 12782 (watchmessagefifo): 12782 pts/1    00:00:00 bash
DEBUGNOTE[19:13:58,341]: x11docker exit code: 0

According to the changelog this should work, since it was added in 2019: https://github.com/mviereck/x11docker/blob/27bbd2578d60dcc92c9fe9a36f4b385b9c2ef0b1/CHANGELOG.md#changed-6

The x11docker command used for execution:

DISPLAY=:0 x11docker --gpu --hostdisplay --sudouser --user=RETAIN --verbose --env COMMIT=localexecution --env STAGE=test -- "-v /mnt/c/scripts/screenshots:/test/screenshots" testexecuternvidiacuda

Would appreciate if the issue could be checked. Great project by the way!

Best regards, Philipp

mviereck commented 3 years ago

Thank you for the report!

I can reproduce the issue. I'll have a look at it.

mviereck commented 3 years ago

Fixed in current master version v6.9.1-beta-9. You can update with x11docker --update-master.


DISPLAY=:0 x11docker --gpu --hostdisplay --sudouser --user=RETAIN --verbose --env COMMIT=localexecution --env STAGE=test -- "-v /mnt/c/scripts/screenshots:/test/screenshots" testexecuternvidiacuda

I recommend to change the syntax after -- to:

x11docker [...] -- -v /mnt/c/scripts/screenshots:/test/screenshots -- testexecuternvidiacuda

This fits the syntax of RUN_OPTIONS given in x11docker --help:

  x11docker IMAGE
  x11docker [OPTIONS] IMAGE [COMMAND]
  x11docker [OPTIONS] -- IMAGE [COMMAND [ARG1 ARG2 ...]]
  x11docker [OPTIONS] -- RUN_OPTIONS -- IMAGE [COMMAND [ARG1 ARG2 ...]]
philippthiele commented 3 years ago

Thank you very much for the quick fix! Will test tomorrow and let you know the result/close the issue.

philippthiele commented 3 years ago

Somehow I cannot use x11docker anymore, it always states "can't open display :0", using runx directly though works, which is strange. But I think this has nothing to do with this issue, so thanks for fixing this!

mviereck commented 3 years ago

Could you open a new ticket where you show how you run x11docker with runx? Your shown syntax with DISPLAY=:0 x11docker [...] is unusual.

Edit: I assume not using DISPLAY=:0 might already fix the issue. If DISPLAY is set elsewhere but invalid, specify option --runx.