Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quoted image command arguments are not parsed accordingly #112

Closed
eine opened this issue Jan 29, 2019 · 4 comments
Closed

Quoted image command arguments are not parsed accordingly #112

eine opened this issue Jan 29, 2019 · 4 comments
Labels

Comments

@eine
Copy link
Contributor

eine commented Jan 29, 2019

I am trying to execute winpty docker run --rm -it x11docker/xfce bash -c "ls && pwd" with x11docker.

  • ./x11docker -i -t x11docker/xfce bash: works, but it not what I want.
  • ./x11docker -i -t x11docker/xfce ls: does not show the output of ls.
  • ./x11docker -i -t x11docker/xfce ls && pwd: the output from x11docker is shown and then pwd is executed in the host. The output of ls is not shown.
  • ./x11docker -i -t x11docker/xfce bash -c "ls && pwd": -c is considered to be the option --clipboard of x11docker, so a warning is shown:
...
x11docker WARNING: Option --clipboard is not supported for --tty.
  Fallback: Disabling option --clipboard.

x11docker note: Did not find container init system 'tini'.
  This is a bug in your distributions docker package.
  Normally, docker provides init system tini as '/usr/bin/docker-init'.

  x11docker uses tini for clean process handling and fast container shutdown.
  To provide tini yourself, please download tini-static:
    https://github.com/krallin/tini/releases/download/v0.18.0/tini-static
  Store it in one of:
    /home/eine/.local/share/x11docker/
    /usr/local/share/x11docker/

/fakehome/eine
/usr/bin/ls: /usr/bin/ls: cannot execute binary file
...
x11docker note: Did not find container init system 'tini'.
  This is a bug in your distributions docker package.
  Normally, docker provides init system tini as '/usr/bin/docker-init'.

  x11docker uses tini for clean process handling and fast container shutdown.
  To provide tini yourself, please download tini-static:
    https://github.com/krallin/tini/releases/download/v0.18.0/tini-static
  Store it in one of:
    /home/eine/.local/share/x11docker/
    /usr/local/share/x11docker/

eine@2aa7533005d5:~$ exit
exit

NOTE: with ./x11docker -i -t x11docker/xfce "ls -la && bash" the output is:

eine@0bc040f292cf:~$ exit
exit
total 24
drwxr-xr-x 2 eine None 4096 Jan 29 22:42 .
drwxrwxrwx 3 root root 4096 Jan 29 22:42 ..
-rw------- 1 eine None    5 Jan 29 22:42 .bash_history
-rw-r--r-- 1 eine None  220 Jan 29 22:42 .bash_logout
-rw-r--r-- 1 eine None 3526 Jan 29 22:42 .bashrc
-rw-r--r-- 1 eine None  807 Jan 29 22:42 .profile

NOTE: ./x11docker -i -t x11docker/xfce "pwd && bash" shows the output of pwd.

However, in neither case is a command prompt provided after. The container exists instead. This is different from the results reported in #110.

  • ./x11docker -i -t x11docker/xfce bash "ls && bash": as in the previous case, ls is not executed at first, but a bash is provided. After exiting, ls is executed, but it fails now.
...
x11docker WARNING: Option --clipboard is not supported for --tty.
  Fallback: Disabling option --clipboard.

x11docker note: Did not find container init system 'tini'.
  This is a bug in your distributions docker package.
  Normally, docker provides init system tini as '/usr/bin/docker-init'.

  x11docker uses tini for clean process handling and fast container shutdown.
  To provide tini yourself, please download tini-static:
    https://github.com/krallin/tini/releases/download/v0.18.0/tini-static
  Store it in one of:
    /home/eine/.local/share/x11docker/
    /usr/local/share/x11docker/

eine@e489ccf9645b:~$ exit
exit
/usr/bin/ls: /usr/bin/ls: cannot execute binary file
  • ./x11docker -i -t x11docker/xfce bash "ls && pwd && bash": same as the previous case.

  • ./x11docker -i -t x11docker/xfce bash "ls; pwd; bash": same as the previous case.

  • ./x11docker -i -t x11docker/xfce bash -c "ls && bash": same as the case without -c, but with the note about --clipboard.

@mviereck mviereck added the bug label Jan 29, 2019
mviereck added a commit that referenced this issue Jan 29, 2019
@mviereck
Copy link
Owner

mviereck commented Jan 29, 2019

Two bugs come together here, one in x11docker and one in x11docker/xfce image.

8d30aa4 fixes the bug in x11docker. The quotes around "ls && pwd" are now preserved accurately. The fix also preserves quotes in DOCKER_RUN_OPTIONS.
The fix changes the generated docker command and the image command in x11docker.CMD.sh. My first tests show now issues.

Image x11docker/xfce contains an ENTRYPOINT script that eats up the quotes (same goes for x11docker/lxde). I'll remove that script, it copies files from /etc/skel to HOME. But this has to wait until I push the next x11docker release that does the copy on itself.

Meanwhile you can test e.g.

x11docker -ti -- x11docker/fvwm sh -c "ls -la ; pwd ; sh"

x11docker -i -t x11docker/xfce bash -c "ls && bash"
with the note about --clipboard.

The -c is parsed as clipboard option and not used as part of the image command. The correct syntax uses -- to divide x11docker options from image command options:
x11docker -i -t -- x11docker/xfce bash -c "ls && bash"

./x11docker -i -t x11docker/xfce ls: does not show the output of ls.

Note that ls in empty HOME does not show any output. Rather check with ls -la

@eine
Copy link
Contributor Author

eine commented Jan 29, 2019

I pulled the latest master and I tried:

# ./x11docker -ti -- x11docker/fvwm sh -c "ls -la ; pwd ; sh"
...
Image 'sh' not found locally.
Do you want to pull it from docker hub? [Y|n]
(Will wait up to 60s for a response, otherwise assuming no)y
/c/Users/eine/x11docker/cache/sh-42d07a/dockerrc: line 123: notify-send: command not found
Using default tag: latest
x11docker note: Pulling image sh from docker hub

Error response from daemon: pull access denied for sh, repository does not exist or may require 'docker login'

x11docker ERROR: Did not find image sh.
  Please build image first or pull it from docker hub with:

      docker pull sh

  or run x11docker with option --pull=yes

  Type 'x11docker --help' for usage information
  Debug options: '--verbose' (full log) or '--debug' (log excerpt).
  Logfile will be: /c/Users/eine/x11docker/cache/x11docker.log
  Please report issues at https://github.com/mviereck/x11docker

./x11docker: line 448: /c/Users/eine/x11docker/cache/sh-42d07a/message.log: No such file or directory
./x11docker: line 448: /c/Users/eine/x11docker/cache/sh-42d07a/message.log: No such file or directory
./x11docker: line 448: /c/Users/eine/x11docker/cache/sh-42d07a/message.log: No such file or directory
./x11docker: line 448: /c/Users/eine/x11docker/cache/sh-42d07a/message.log: No such file or directory

But this has to wait until I push the next x11docker release that does the copy on itself.

I'll try with other images meanwhile.

Meanwhile you can test e.g.

 x11docker -ti -- x11docker/fvwm sh -c "ls -la ; pwd ; sh"

I tried, but it fails as shown above. I think that this is related to the fix, rather than to the image. The same happens with x11docker -i -t -- x11docker/xfce bash -c "ls && bash".

The correct syntax uses -- to divide x11docker options from image command options:

I always forget about it when I don't put docker run options. Thanks for the remainder.

@mviereck
Copy link
Owner

I tried, but it fails as shown above. I think that this is related to the fix, rather than to the image. The same happens with x11docker -i -t -- x11docker/xfce bash -c "ls && bash".

Stupid me, I should have tested without DOCKER_RUN_OPTIONS, too. Is fixed now.

@mviereck mviereck changed the title [--interactive] CLI argument for docker (after <image>) processed as x11docker option Quoted image command arguments are not parsed accordingly Jan 30, 2019
@eine
Copy link
Contributor Author

eine commented Jan 30, 2019

It works great now! I believe we can close this too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants