LXC Host
Contents
CentOS 7
Basic Install
[root@web ~]# yum install epel-release [root@web ~]# yum install debootstrap perl libvirt [root@web ~]# yum install lxc lxc-templates
Storage
[3]It appears you can change the defualt directory to store containers by modifying /etc/lxc/lxc.conf (and NOT default.conf)[4]
lxc.lxcpath = /raid5/services/containers
Troubleshooting
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[5]
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)
- ↑ http://www.tecmint.com/install-create-run-lxc-linux-containers-on-centos/
- ↑ https://stgraber.org/2013/12/27/lxc-1-0-container-storage/
- ↑ https://stackoverflow.com/questions/25286546/change-lxc-container-directory
- ↑ https://github.com/lxc/lxc/issues/208
- ↑ http://lxc-users.linuxcontainers.narkive.com/R1ziqqL4/lxc-ls-question