Lxc
CentOS
Add EPEL repository
http://www.tecmint.com/how-to-enable-epel-repository-for-rhel-centos-6-5/
## RHEL/CentOS 7 64-Bit ## wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm rpm -ivh epel-release-7-5.noarch.rpm
Install LXC
yum install lxc lxc-templates
Other install
yum install bridge-utils
yum install -y libvirt systemctl start libvirtd brctl show
bridge name bridge id STP enabled interfaces virbr0 8000.fea2866efadb yes veth7ATCJK
Config
vi /var/lib/lxc/centos1/config
The startup related values that are available are:
lxc.start.auto = 0 (disabled) or 1 (enabled) lxc.start.delay = 0 (delay in second to wait after starting the container) lxc.start.order = 0 (priority of the container, higher value means starts earlier) lxc.group = group1,group2,group3,… (groups the container is a member of)
Prevent excess journald activity
By default, lxc symlinks /dev/kmsg to /dev/console, this leads to journald running at 100% CPU usage all the time. To prevent the symlink, use:
vi /var/lib/lxc/centos1/config
lxc.kmsg = 0
More info: https://wiki.archlinux.org/index.php/Linux_Containers#Systemd_considerations_.28required.29
Image creation
lxc-create -n centos1 -t centos lxc-start -n centos1
Login to Container: The root password is set in the lxc template.
Normal operations
Start
lxc-start -n centos1
Attach
lxc-attach -n centos1
Stop
To stop:
lxc-stop -n centos1
To kill:
lxc-stop -n centos1 -k
LAMP installation
yum install httpd systemctl enable httpd
only before Centos7:
sudo yum install mysql-server sudo service mysqld start sudo /usr/bin/mysql_secure_installation
On Centos7 install MariaDB: https://downloads.mariadb.org/mariadb/repositories/#mirror=host-europe&distro=CentOS&distro_release=centos7-amd64--centos7&version=10.1
Here is your custom MariaDB YUM repository entry for CentOS. Copy and paste it into a file under /etc/yum.repos.d/ (we suggest naming the file MariaDB.repo or something similar).
# MariaDB 10.1 CentOS repository list - created 2016-02-29 20:27 UTC # http://mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.1/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
After the file is in place, install MariaDB with:
sudo yum install MariaDB-server MariaDB-client
sudo yum install php php-mysql yum search php- yum info name of the module yum install php-fpm
sudo chkconfig httpd on sudo chkconfig mysqld on
more info:
- https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-centos-6
- https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-centos-7
Fix for Apache
https://www.marc.info/?l=lxc-users&m=142483647735314&w=2 I have trouble updating httpd in my containers. > containers, LXC 1.0.3 > >
>error: unpacking of archive failed on file /usr/bin/systemd-detect-virt: > cpio: cap_set_file >
Look for /usr/share/lxc/config/fedora.common.conf (or whatever it is on fedora, try "rpm -ql lxc"), then comment out this line
vi /usr/share/lxc/config/centos.common.conf lxc.cap.drop = setfcap
Other info
Migrate/convert existing full CentOS 6 server to LXC container: http://blog.a2o.si/2015/10/11/migrate-convert-existing-full-centos-6-server-to-lxc-container/
Linux, Apache, MySQL, PHP in an LXC Container: https://zyisrad.com/linux-apache-mysql-php-in-an-lxc-container/
Pacman roseta https://wiki.archlinux.org/index.php/Pacman/Rosetta
General info: "Linux, Apache, MySQL, PHP in an LXC Container" https://zyisrad.com/linux-apache-mysql-php-in-an-lxc-container/