Difference between revisions of "LXC Host"

From Michael's Information Zone
Jump to navigation Jump to search
Line 80: Line 80:
 
</pre>
 
</pre>
 
I think we have success!
 
I think we have success!
 +
 +
===Unit lxc.service could not be found===
 +
When I was first installing LXC, my server ended up dying on me. After moving drives to a new system I found LXC to be corrupted. A re-install was needed.
 +
<pre>
 +
[root@nas ~]# systemctl status lxc
 +
Unit lxc.service could not be found.
 +
[root@nas ~]# yum reinstall $(yum list installed | grep lxc | awk '{print $1}')
 +
...
 +
[root@nas ~]# systemctl status lxc
 +
● lxc.service - LXC Container Initialization and Autoboot Code
 +
  Loaded: loaded (/usr/lib/systemd/system/lxc.service; disabled; vendor preset: disabled)
 +
  Active: inactive (dead)
 +
 +
</pre>

Revision as of 10:16, 22 September 2018

CentOS 7

Basic Install

[1][2]

[root@web ~]# yum install epel-release
[root@web ~]# yum install debootstrap perl libvirt
[root@web ~]# yum install lxc lxc-templates

ImportError: No module named 'lxc'

I ran into a problem when trying to list my containers.

[root@nas ~]# lxc-ls
Traceback (most recent call last):
  File "/usr/bin/lxc-ls", line 31, in <module>
    import lxc
ImportError: No module named 'lxc'

I assumed this was a kernel module which really messed me up. After a lot of wasted time I found out that this is a python module[3]
At this point I searched for the package but could not find it.

[root@nas ~]# yum search python | grep python | grep lxc
python2-lxc.x86_64 : Python2 bindings for LXC
python34-lxc.x86_64 : Python binding for lxc

Looks like python34-lxc is what I need. So I check my installed packages

[root@nas ~]# yum list installed | grep python | grep lxc
python34-lxc.x86_64  

It is already installed. So lets try re-installing

[root@nas ~]# yum reinstall python34-lxc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.usinternet.com
 * epel: mirror.rnet.missouri.edu
 * extras: centos2.zswap.net
 * nux-dextop: li.nux.ro
 * updates: mirror.atlanticmetro.net
Resolving Dependencies
--> Running transaction check
---> Package python34-lxc.x86_64 0:1.0.11-1.el7 will be reinstalled
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================================================================================================
 Package                                               Arch                                            Version                                                 Repository                                     Size
===================================================================================================================================================================================================================
Reinstalling:
 python34-lxc                                          x86_64                                          1.0.11-1.el7                                            epel                                           25 k

Transaction Summary
===================================================================================================================================================================================================================
Reinstall  1 Package

Total download size: 25 k
Installed size: 54 k
Is this ok [y/d/N]: y
Downloading packages:
python34-lxc-1.0.11-1.el7.x86_64.rpm                                                                                                                                                        |  25 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python34-lxc-1.0.11-1.el7.x86_64                                                                                                                                                                1/1 
  Verifying  : python34-lxc-1.0.11-1.el7.x86_64                                                                                                                                                                1/1 

Installed:
  python34-lxc.x86_64 0:1.0.11-1.el7                                                                                                                                                                               

Complete!

Now lets try again

[root@nas ~]# lxc-ls
[root@nas ~]# 

I think we have success!

Unit lxc.service could not be found

When I was first installing LXC, my server ended up dying on me. After moving drives to a new system I found LXC to be corrupted. A re-install was needed.

[root@nas ~]# systemctl status lxc
Unit lxc.service could not be found.
[root@nas ~]# yum reinstall $(yum list installed | grep lxc | awk '{print $1}')
...
[root@nas ~]# systemctl status lxc
● lxc.service - LXC Container Initialization and Autoboot Code
   Loaded: loaded (/usr/lib/systemd/system/lxc.service; disabled; vendor preset: disabled)
   Active: inactive (dead)