[lxc-users] : Redirecting output of attach_wait

Heena Sirwani heenasirwani at gmail.com
Wed Jun 8 07:19:43 UTC 2016


A question regarding the same:
I was wondering how attach_wait with run_command and run_shell works. Any
description or documentation for the same?
When I am executing a shell script that I previously copied into the
container file system with a hook for pre-start, I do it with
attach_wait(lxc.attach_run_command,[script-path, args, ">", "file in the
container", "2>&1"]),

1. I don't see the file with output in the container
2. If I redirect the output inside the script using  > $HOME/file, I see
$HOME pointing to my host home.

I would like to know the working of attach_wait to debug the same.
>From the source I could get the following:
1. From attach_run_shell - it only starts a shell inside the container
How do I execute a program from this shell?

2. From attach_run_command- I can see it executes a process using execvp.
So I assume the process is spawned from the host's namespace, hence $HOME
still has host's home.
>From this I inferred, I have to use $LXC_ROOTFS_PATH. How do I get the
default username configured to login to the container?:
eg:${LXC_ROOTFS_PATH}/home/ubuntu

3. How to I pass arguments to the hook scripts? I know there are some
environment variables passed and one can define environment variables using
lxc.environment. But I do not wish to set environment variables but to
pass arguments to the hook scripts.

Is there any documentation for attach_wait?
If not, I would volunteer for writing the same.

Thanks,
Heena


On Tue, Jun 7, 2016 at 3:04 PM, Heena Sirwani <heenasirwani at gmail.com>
wrote:

> Hi all,
>
> How do I run attach_wait in quiet mode or redirect its output somewhere
> else?
> I do not wish to see the output from my host. I redirect the output in the
> container. However, I see the output in the host from where the script is
> run.
>
> Am I missing something?
>
> Thanks,
> Heena
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20160608/a8ffea5c/attachment.html>


More information about the lxc-users mailing list