LXC and Virtual Machine Manager

Can someone point me to a how-to on how to use LXC and Virtual Machine Manager? I’m new to LXC so I kind of don’t know exactly how it works. In the GUI, I chose “operating system container”, then the next screen is OS root directory, which I entered “/” and it booted. When I installed the app I wanted to install (plex) it installed on the host machine.

Some help would be appreciated!

Is there a reason you want to use lxc over virtual machines?
My opinion is if you want to learn more about them than build and set it up from command line. I have messed with lxc a bit and someone else on this form has some more extensive work from them. @Vitalius seems to know some more than me.


There is a thread where a few of us discussed lxc and some links to helpful tutorials if I remember correctly.
Not turning you away from it just want some further insight so I can help you more.

1 Like

It asked you for the root of the container. Of course the root of your host is /, why would VMM even have to ask that? So you actually did install plex into the container, but you were really just using your host as container.

You first have to create a directory that will act as the container’s root and put all of the container’s files into it. Then run VMM and point it to that directory. I’m pretty sure VMM tells you this on container creation.

1 Like

I suggest learning about containers, how they operate and the file system hierarchy of Linux. There are many good talks/presentations on YouTube.

I don’t know what GUI or whatever you are using. But to give you the quick rundown: Containers have a root directory on your hosts file system. Remember your hosts file system always starts with “/”. When running a container (LXC, Jails, Zones) LXC in your case, a directory must be created on the host (such as “/containers/lxc/ubuntu”) to house the file system the container needs. What you have done is made the containers root directory the same as your hosts.

EDIT: Reply mistake sorry.
May as well reply now :slight_smile:

Containers do not carry the overhead of full hardware level virtualisation. Containers have the native performance and at least in the case of Zones not LXC might actually be be more secure lol. Also to be more clear the container appears almost like a full linux instance however it is not a VM. Inside of the container it would also be like running on the host of course with some restrictions for security.

1 Like

Yeah, I haven’t used virtual machine manager, but the advantages of LXCs are they’re faster and vastly more resource efficient than VMs.

For example, look at my pihole LXC. It’s using only 235MB RAM and 194MB of disk space, and yet it behaves like a real separate host. It has its own IP, you can SSH into it, you can apt install whatever you want, and it has complete resource separation from the host. I can take a snapshot in 2 seconds, SSH in, rm -rf /, then restore the snapshot and it’s right back where it was. LXCs are awesome.

Name: pihole
Remote: unix://
Architecture: x86_64
Created: 2018/07/31 04:05 UTC
Status: Running
Type: persistent
Profiles: default
Pid: 1002
Ips:
  eth0: inet    10.0.10.201
  eth0: inet6   fe00::216:3eff:fe5c:3583
  lo:   inet    127.0.0.1
  lo:   inet6   ::1
Resources:
  Processes: 64
  Disk usage:
    root: 193.95MB
  CPU usage:
    CPU usage (in seconds): 360
  Memory usage:
    Memory (current): 234.21MB
    Memory (peak): 376.54MB
  Network usage:
    eth0:
      Bytes received: 0B
      Bytes sent: 0B
      Packets received: 0
      Packets sent: 0
    lo:
      Bytes received: 29.64MB
      Bytes sent: 29.64MB
      Packets received: 98881
      Packets sent: 98881

On one hand, I haven’t touched LXC in ages. On the other, I use Docker at work now.

This is correct. It was asking for where the root of the container was. Not where the root of your host operating system was.

The others have said what I would.

@hondaman You should probably read the pages on this website: https://linuxcontainers.org/

I like LXC more than docker for home lab stuff because they work like VMs, you aren’t reliant on some maintainer to update the container on docker-hub. It’s also much, much easier to get LXCs to DHCP IPs via MACVLAN so they show up on your LAN. Possible on docker also but kind of a pain in the ass.

Of course the downside is you need to update the containers yourself, but I just setup automatic updates and it’s all good.

I’ll be honest I’m not a big fan of LXC on its own with just Virt-manager. It is very painful and a bit limited.

As others have said you need to specify a folder where the root file system you want for the container to be is per container to then run of. Cause you just did / you told the container to use the rootfs of the host instead.

You could just do from the terminal/SSH:
cd /
mkdir rootfs

To make a folder in the the root of the host called rootfs to then point your container at but you still need to popular that folder with the necessary files for it to be a viable root file system and that can vary depending on what distro you want to run a container of as to the right process.

Honestly I would recommend looking at LXD on Ubuntu. It is built on top of LXC but fixes a lot and is a much more straightforward experience to get a container to just work. Plus Ubuntu s documentation is quite good to get you up and running quickly when you are just starting out. You can just pull a complete base image down and let it handle setting up root file systems and so on.

https://www.ubuntu.com/containers/lxd

1 Like

Yes, I use LXD to manage my many containers. Works great.

2 Likes

LXD works on Opensuse as well. I tried it out and set up a couple of containers and it was easy and worked well.
Opensuse LXD installation info are here:

https://linuxcontainers.org/lxd/getting-started-cli/

1 Like

You want to use snap for LXD, the packaged versions are pretty far behind now. All active development is on the snap versions.

1 Like

Yes you can - I actually tried it out recently and it does work well. Much easier then trying to get LXC working on SUSE that’s for sure :smile: