3
votes

I was thinking that 64 bit host machine can launch 32 bit LXC as we have a option of specifying arch during LXC creation.

 hostmc$> lxc-create -n ubuntu -t ubuntu -- i386

Host machine:

 hostmc$> uname -a Linux D 3.11.0-26-generic #45~precise1-Ubuntu SMP Tue Jul 15 04:02:35 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

But then on login in to the 32 bit LXC container, I find uname -a specify the arch as x86_64 and even running file command also specify the arch as x86_64 instead of i386

   hostmc$> lxc-console -n ubuntu

   ubuntu@ubuntu:~$ uname -a
   Linux ubuntu 3.11.0-26-generic #45~precise1-Ubuntu SMP Tue Jul 15 04:02:35 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

   ubuntu@ubuntu:~$ file /bin/ls
   /bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x37cdd635587f519989044055623abff939002027, stripped
3

3 Answers

3
votes

On my Debian 8.2 (jessie), I get:

root@srv1:~# uname -a
Linux srv1 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1+deb8u4 (2015-09-19) x86_64 GNU/Linux

root@srv1:~# lxc-create -n vm -t debian --dir /data/vm -- -a i386
...
root@srv1:~# lxc-start -n vm
...
(in the VM)
root@vm:~# uname -a
Linux vm 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1+deb8u4 (2015-09-19) i686 GNU/Linux

The key difference with your example is the -a flag.

1
votes

Although this is late, but it might be helpful to someone.

I did it in Ubuntu Bionic with a Bionic 32-bit guest with the following:

sudo lxc launch images:ubuntu/18.04/i386 GuestName
# run with 
sudo lxc exec GuestName bash

and uname -a returns:

Linux MachineName 4.15.0-46-generic #49-Ubuntu SMP Wed Feb 6 09:33:07 UTC 2019 i686 i686 i686 GNU/Linux

So it's 32-bit, and the application I'm debugging confirmed it.

0
votes

When the host runs a 64 bit system the containers will always show a 64 bit system when you execute uname.

Containers and the host share the same Linux kernel instance. Containers are encapsulated processes but they still run in the host kernel. And if the host kernel is a 64 bit kernel the container processes are always processes that are executed 64 bit.