Can't create container
I'm having trouble finding a tutorial that I can follow without failing at the create container stage.
Python 3.6.8 (default, Aug 24 2020, 17:57:11)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxc
>>> container = lxc.Container('test')
>>> container.create('busybox')
False
Same problem, creating a container fails when using regular user, even the provided examples do not pass their own tests unless you use sudo.
Python 3.10.6 (main, Aug 10 2022, 11:40:04) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxc
>>> container = lxc.Container("test")
>>> container.create("download", 0, {"dist": "ubuntu", "release": "xenial", "arch": "amd64"})
False
Also tried with architecture as x86_64 yet it does not work and there are no useful error messages.
lxc: 3.0.4.0
Apparently after digging in lxc/__init__.py the following will create the container using regular user where you should create a directory in ~/{username}/.local/share/lxc:
Python 3.10.6 (main, Aug 10 2022, 11:40:04) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxc
>>> container = lxc.Container("test")
>>> container.create(template=None, flags=0, args={"dist": "ubuntu", "release": "xenial", "arch": "amd64"})
True
Although no containers will actually be downloaded.
To get this to work you have to run your Python REPL using sudo.
Python 3.10.6 (main, Aug 10 2022, 11:40:04) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxc
>>> container = lxc.Container("test")
>>> container.create(template="download", args={"dist": "ubuntu", "release": "xenial", "arch": "amd64"})
Using image from local cache
Unpacking the rootfs
---
You just created an Ubuntu xenial amd64 (20221028_07:42) container.
True
>>> container.defined
True
>>> container.start()
True
>>> container.state
'RUNNING'
>>> container.stop()
True
>>> container.destroy()
True
>>> container.defined
False