On Thu, Mar 23, 2017 at 3:39 PM, Francesco Longo <flo...@unime.it> wrote:
> Thanks for your reply. It seems that if I put a sleep after container
> creation _sometimes_ it works. Probably, I have to play with the delay.
>
> Is there a correct way to do that? I mean, is there a way to execute a set
> of commands inside the container after the container has properly booted? I
> guess that I could use cloud-init but that means it would work only in
> ubuntu images right?
>

Add some code that will check whether the "ubuntu" account has been
created in the container.
If it has not been created yet, you can "sleep 1", and check again.
Keep checking until the account gets created.

Simos

> Francesco
>
>
> On Thu, Mar 23, 2017 at 12:32 PM, Simos Xenitellis
> <simos.li...@googlemail.com> wrote:
>>
>> On Thu, Mar 23, 2017 at 12:41 PM, Francesco Longo <flo...@unime.it> wrote:
>> > Hi all,
>> > I'm playing with Raspberry Pi virtualization, i.e., in few words,
>> > creating
>> > LXD containers on top of a Raspberry Pi and attaching to them a couple
>> > of
>> > FUSE filesystems mirroring the GPIO /sys/class/gpio filesystem.
>> >
>> > I created a simple script that you can find here:
>> >
>> > https://github.com/flongo82/raspberry_virtualization/blob/master/launch_virtual_rasp.sh
>> >
>> > A first issue I'm dealing with is that when using lxc exec to add the
>> > ubuntu
>> > user to the gpio groups it says that the ubuntu user does not exist.
>> > But, if
>> > I login into the container the user is actually there but, of course, it
>> > is
>> > not part of the gpio group given that the command has failed.
>> >
>> > This is the output of the script:
>> >
>> > Creating virtual rasp test!
>> > Creating test
>> > Starting test
>> > Adding group `gpio' (GID 1000) ...
>> > Done.
>> > usermod: user 'ubuntu' does not exist
>> > Device gpio added to test
>> > Device devices added to test
>> >
>> > Any idea why this is happening? Is it possible that I need to wait a
>> > while
>> > before issuing this kind of lxc exec command after creating the
>> > container?
>>
>> You can look into the image at /var/lib/lxd/images/
>> and you will verify that the "ubuntu" account is not preinstalled in the
>> image.
>> In there you can see that there exist cloud-init templates that do things
>> like creating users. My quick look did not show which template creates
>> the "ubuntu" user,
>> so have a better look in there.
>> "cloud-init" runs after the container is created, therefore it makes
>> sense is the "ubuntu" account
>> is not available exactly after the exit for "lxc launch".
>>
>> Simos
>>
>> >
>> > I'm using LXD version 2.12 on top of a
>> > ubuntu-16.04-preinstalled-server-armhf+raspi3.img.xz image.
>> >
>> > Thanks,
>> > Francesco
>> >
>> > --
>> >
>> > ------------------------------------------------------------------------------
>> > Dr. Francesco Longo, PhD
>> > Assistant Professor
>> > Dipartimento  di Ingegneria
>> > Università degli Studi di Messina
>> > address: Contrada di Dio (S. Agata), 98166, Messina, Italy
>> > email: flo...@unime.it
>> > phone: +39 090 3977335 --- fax: +39 090 3977471
>> >
>> > ------------------------------------------------------------------------------
>> >
>> > _______________________________________________
>> > lxc-users mailing list
>> > lxc-users@lists.linuxcontainers.org
>> > http://lists.linuxcontainers.org/listinfo/lxc-users
>> _______________________________________________
>> lxc-users mailing list
>> lxc-users@lists.linuxcontainers.org
>> http://lists.linuxcontainers.org/listinfo/lxc-users
>
>
>
>
> --
> ------------------------------------------------------------------------------
> Dr. Francesco Longo, PhD
> Assistant Professor
> Dipartimento  di Ingegneria
> Università degli Studi di Messina
> address: Contrada di Dio (S. Agata), 98166, Messina, Italy
> email: flo...@unime.it
> phone: +39 090 3977335 --- fax: +39 090 3977471
> ------------------------------------------------------------------------------
>
> _______________________________________________
> lxc-users mailing list
> lxc-users@lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-users
_______________________________________________
lxc-users mailing list
lxc-users@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-users

Reply via email to