lxc stand for Linux Container.
Now i will start to describe how to create container using this command
- You need to know when lxc installed, it’s create file under /etc/lxc/ called default.conf this file should contain your network interface name and you need to add it.
[root@OEL6 ~]# cat /etc/lxc/default.conf
lxc.network.type = veth
lxc.network.link = docker0
lxc.network.flags = up
Sample output for ifconfig command :
docker0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
inet addr:172.17.42.1 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::28ce:eeff:fe80:1fc8/64 Scope:Link
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:17 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1112 (1.0 KiB) TX bytes:408 (408.0 b)
[root@OEL6 container]# lxc-start –name test-container
lxc-start: failed to attach ‘vethaITNmu’ to the bridge ‘virbr0’ : No such device
lxc-start: failed to create netdev
lxc-start: failed to create the network
lxc-start: failed to spawn ‘test-container’
- Before Create any container you need to create Directory under /, if you don’t do this step another error will be appeared asking for this directory and telling you /container not found.
mkdir /container will solve the problem.
Now Let’s Start Creating new container called Test-container :
[root@OEL6 lxc]# lxc-create -n test-container -t oracle — -R 6.5
lxc-create: No config file specified, using the default config /etc/lxc/default.conf
Host is OracleServer 6.5
Create configuration file /container/test-container/config
Downloading release 6.5 for x86_64
Loaded plugins: refresh-packagekit, security
ol6_u5_base | 1.4 kB 00:00
ol6_u5_base/primary | 3.2 MB 00:32
ol6_u5_base 8573/8573
Setting up Install Process
Complete!
Rebuilding rpm database
Configuring container for Oracle Linux 6.5
Added container user:oracle password:oracle
Added container user:root password:root
Container : /container/test-container/rootfs
Config : /container/test-container/config
Network : eth0 (veth) on virbr0
‘oracle’ template installed
‘test-container’ created
[root@OEL6 lxc]# lxc-start -n test-container
Welcome to Oracle Linux Server
Setting hostname test-container: [ OK ]
Checking filesystems
[ OK ]
Mounting local filesystems: [ OK ]
No such file or directory
Enabling /etc/fstab swaps: [ OK ]
Entering non-interactive startup
Bringing up loopback interface: [ OK ]
Bringing up interface eth0:
Determining IP information for eth0… failed.
[FAILED]
Starting system logger: [ OK ]
Mounting filesystems: [ OK ]
Generating SSH1 RSA host key: No such file or directory
[ OK ]
Generating SSH2 RSA host key: No such file or directory
[ OK ]
Generating SSH2 DSA host key: No such file or directory
[ OK ]
Starting sshd: [ OK ]
Oracle Linux Server release 6.5
Kernel 3.8.13-16.2.1.el6uek.x86_64 on an x86_64
test-container login:
lxc-destroy -n test-container
Reference :
1- Oracle Linux containers Here
2- Oracle Linux 6.5 and Docker Here
Thank you
Osama mustafa