Lxd: Cannot use paranthesis with exec command

Created on 20 Jun 2015  路  1Comment  路  Source: lxc/lxd

From my understanding lxc exec should work similar to passing commands via SSH. However I cannot issue multiple commands in parenthesis:

Runs first command in the container, and the second on on the host:

lxc exec container -- ls -a & top

Doesn't work

lxc exec maas -- "ls -a & top"
lxc: attach.c: lxc_attach_run_command: 1107 No such file or directory - failed to exec 'ls -a & top'

Most helpful comment

Yeah, we can't make that part work like ssh. The reason for this is that ssh knows what your shell is inside the container, we don't.
When ssh detects shell specific characters being used, it spawns the shell and pass the command to it, rather than spawning it itself.

Anyway, the result is, we can't implement this behavior in LXD.
The good news though is that you can do it yourself on the client with:

lxc exec maas -- /bin/sh -c "ls -a & top"

Assuming that /bin/sh is a valid shell.

>All comments

Yeah, we can't make that part work like ssh. The reason for this is that ssh knows what your shell is inside the container, we don't.
When ssh detects shell specific characters being used, it spawns the shell and pass the command to it, rather than spawning it itself.

Anyway, the result is, we can't implement this behavior in LXD.
The good news though is that you can do it yourself on the client with:

lxc exec maas -- /bin/sh -c "ls -a & top"

Assuming that /bin/sh is a valid shell.

Was this page helpful?
0 / 5 - 0 ratings