Lxc: diferència entre les revisions

De WikiMar
Salta a la navegació Salta a la cerca
Línia 39: Línia 39:




===Normaloperations===
===Normal operations===


====Start====
====Start====
  lxc-start -n <container_name>
  lxc-start -n centos1


====Attach====
====Attach====
  lxc-attach -n <container_name>
  lxc-attach -n centos1


====Stop====
====Stop====
Línia 53: Línia 53:
To kill:
To kill:
  lxc-stop -n centos1 -k
  lxc-stop -n centos1 -k


===LAMP installation===
===LAMP installation===

Revisió del 19:25, 29 feb 2016

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


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/centos/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
sudo yum install mysql-server
sudo service mysqld start
sudo /usr/bin/mysql_secure_installation
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:


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/