Difference between revisions of "Setting up basic lxc application or OS container in Cent-OS 6.3"
From Notes_Wiki
m |
m |
||
Line 24: | Line 24: | ||
# Chroot to container folder and do the following | # Chroot to container folder and do the following | ||
## Edit file '<tt>/etc/rc.d/rc.sysinit</tt>' of the container and comment line that starts udev | ## Edit file '<tt>/etc/rc.d/rc.sysinit</tt>' of the container and comment line that starts udev | ||
## Go to '<tt>/etc/sysconfig/network-script/</tt>' and delete '<tt>ifcfg-venet</tt>' etc. files. Create proper '<tt>ifcfg-eth0<tt>' files with following values | ## Go to '<tt>/etc/sysconfig/network-script/</tt>' and delete '<tt>ifcfg-venet</tt>' etc. files. Create proper '<tt>ifcfg-eth0</tt>' files with following values | ||
##:<pre> | ##:<pre> | ||
##:: DEVICE=eth0 | ##:: DEVICE=eth0 |
Revision as of 15:58, 26 July 2014
<yambe:breadcrumb>Lxc</yambe:breadcrumb>
Setting up basic lxc application or OS container in Cent-OS 6.3
To create an application (/bin/bash or /usr/sbin/sshd) or OS container using lxc in Cent-OS use following steps:
- Download latest lxc userspace tools from http://lxc.sourceforge.net/download/lxc/
- Run 'lxc-checkconfig' and ensure that everything appears as enabled.
- Setup bride networking.
- Add line 'BRIDGE=br0' to 'ifcfg-eth0'. Then copy 'ifcfg-eth0' to 'ifcfg-br0'.
- In 'ifcfg-br0' one should have following lines
- DEVICE="br0"
- TYPE=Bridge
- BOOTPROTO=dhcp
- NM_CONTROLLED="no"
- ONBOOT="yes"
- Do 'service network restart'
- Test network connectivity by pinging. Ensure by 'brctl show' that eth0 is connected to br0.
- Download openvz container images from http://wiki.openvz.org/Download/template/precreated
- Use 'virt-manager' GUI and connect to LXC hypervisor. Try to create application container for '/bin/bash' to verify basic working of lxc.
- Create a folder for lxc containers such as '/mnt/data1/lxc'
- Create a folder for first container such as '/mnt/data1/lxc/centos1'
- Extract downloaded openvz container into centos1 folder
- Chroot to container folder and do the following
- Edit file '/etc/rc.d/rc.sysinit' of the container and comment line that starts udev
- Go to '/etc/sysconfig/network-script/' and delete 'ifcfg-venet' etc. files. Create proper 'ifcfg-eth0' files with following values
- DEVICE=eth0
- BOOTPROTO=static
- IPADDR=10.3.3.150
- NETMASK=255.255.255.0
- GATEWAY=10.3.3.1
- DNS1=10.4.3.222
- ONBOOT="yes"
- Use 'passwd' to set root password.
- Edit '/etc/ssh/sshd_config' and set 'UsePAM=no' to disable use of PAM
- Also use 'chkconfig httpd on' to enable starting of apache on start-up. This is not required but helps in testing TCP connections to container in rare case, that SSH is not working.
- Use 'virt-manager' GUI and create a container. Boot it and ping it. Try to ping and open web server of created container.
- Try to ssh to container as root using password set earlier.
<yambe:breadcrumb>Lxc</yambe:breadcrumb>