Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't create container #25

Open
WorksWellWithOthers opened this issue Jan 14, 2021 · 2 comments
Open

Can't create container #25

WorksWellWithOthers opened this issue Jan 14, 2021 · 2 comments

Comments

@WorksWellWithOthers
Copy link

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
@WMRamadan
Copy link

WMRamadan commented Oct 29, 2022

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

@WMRamadan
Copy link

WMRamadan commented Oct 29, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants