lost and found ( for me ? )

Showing posts with label linux container. Show all posts
Showing posts with label linux container. Show all posts

LXC Web Panel : GUI for Linux Container

about LXC Web Panel

[ install on Ubuntu 13.04 LXC ]

To install LXC Web Panel, we need to meet the following requirements.
Ubuntu 12.04 or higher
LXC 0.8 or higher
/var/lib/lxc as LXC root path

Here is my ubuntu box information.
root@ubuntu:~# tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Ubuntu 13.04"
root@ubuntu:~# lxc-version
lxc version: 0.9.0
root@ubuntu:~# ls /var/lib/lxc/
ubuntu-cn1  ubuntu-cn2
root@ubuntu:~#

installation is very easy. jsut issue “wget ..”
root@ubuntu:~# wget http://lxc-webpanel.github.io/tools/install.sh -O - | bash

Installation complete!


Adding /etc/init.d/lwp...
Done
Starting server...done.
Connect you on http://your-ip-address:5000/
root@ubuntu:~#

root@ubuntu:~# lsof -ni:5000
COMMAND   PID USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
python  11771 root    3u  IPv4 1869384      0t0  TCP *:5000 (LISTEN)

root@ubuntu:~# ps aux | grep 11771 | grep -v grep
root     11771  0.3  0.2  70008 18064 ?        S    02:31   0:02 /usr/bin/python /srv/lwp/lwp.py



config file
I have used a default configuration file.

root@ubuntu:~# cat /srv/lwp/lwp.conf
[global]
address = 0.0.0.0
port = 5000
debug = False

[database]
file = lwp.db

[session]
time = 10

[overview]
partition = /



how to start/stop

root@ubuntu:~# /etc/init.d/lwp status
Usage: /etc/init.d/lwp {start|stop|restart}

root@ubuntu:~# /etc/init.d/lwp stop
Stopping server...Stopped process in pidfile '/var/run/lwp.pid' (pid 11771).
done.

root@ubuntu:~# /etc/init.d/lwp start
Starting server...done.



access to web panel with an web browser
user : admin, pass : admin

You can create/start/stop/reboot containers via HTTP










Ubuntu LXC : use bridge network

small tips.
# lxc-version
lxc version: 0.9.0

# tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Ubuntu 13.04"

# uname -ri
3.8.0-25-generic x86_64

make a bridge network and associate that bridge (br0) with a physical link(eth0).

physical link : eth0
bridge network I made : br0
auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
       address 192.168.100.15
       netmask 255.255.255.0
       network 192.168.100.0
       gateway 192.168.100.254
       bridge_ports eth0
       bridge_stp off
       bridge_fd 0
       bridge_maxwait 0

restart network
# /etc/init.d/networking restart

edit existing containers configuration(/var/lib/lxc/< container name>/config ) to have those containers use the bridge network br0 which is associated with eth0.

container name : ubuntu-cn1
# less /var/lib/lxc/ubuntu-cn1/config
# Template used to create this container: ubuntu
# Template script checksum (SHA-1): 6f468a9a658112f6420fb39d2ab90a80fd43cd22

lxc.network.type = veth
lxc.network.hwaddr = MAC address
#lxc.network.link = lxcbr0
lxc.network.link = br0

edit LXC’s config ( default.conf ) to have containers which I build next time use bridge network.
# less /etc/lxc/default.conf
lxc.network.type = veth
#lxc.network.link = lxcbr0
lxc.network.link = br0
lxc.network.flags = up

Linux container 0.9.0 on Ubuntu 13.04

Here’s how to use LXC ( Linux Container ) on Ubuntu 13.04

# tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Ubuntu 13.04"
root@ubuntu-2:~# uname -ri
3.8.0-25-generic x86_64

install LXC via apt-get
# apt-get install lxc

# dpkg -l lxc
ii  lxc            0.9.0-0ubunt amd64        Linux Containers userspace tools


[ config file ]

I used default configuration files.
# ls /etc/init/lxc*
/etc/init/lxc-instance.conf  /etc/init/lxc-net.conf  /etc/init/lxc.conf

# ls /etc/default/lx*
/etc/default/lxc

template files
# ls /usr/share/lxc/templates/
lxc-alpine     lxc-busybox  lxc-opensuse  lxc-ubuntu
lxc-altlinux   lxc-debian   lxc-oracle    lxc-ubuntu-cloud
lxc-archlinux  lxc-fedora   lxc-sshd

[ build a container by using template files ]

build a ubuntu container with lxc-ubuntu template.
# lxc-create -t ubuntu -n ubuntu-cn1

lxc-create: No config file specified, using the default config /etc/lxc/default.conf
Checking cache download in /var/cache/lxc/raring/rootfs-amd64 ...
<snip>

nn , error
<snip>
Processing triggers for initramfs-tools ...
Download complete
Copy /var/cache/lxc/raring/rootfs-amd64 to /var/lib/lxc/ubuntu-cn1/rootfs ...
Copying rootfs to /var/lib/lxc/ubuntu-cn1/rootfs ...
lxc-create: failed to execute template 'ubuntu'
lxc-create: aborted
#

there is no /var/lib/lxc/ubuntu-cn1 direcoty..
# ls /var/lib/lxc/ubu*
ls: cannot access /var/lib/lxc/ubu*: No such file or directory

make the directory.
# mkdir /var/lib/lxc/ubuntu-cn1

try again. error.
# lxc-create -t ubuntu -n ubuntu-cn1
lxc-create: 'ubuntu-cn1' already exists

remove the directory.
# rm /var/lib/lxc/ubuntu-cn1/ -r

Seen from results of googling “lxc-create: failed to execute template” , someone faced the similar issue when LANG is not valid.

Seen from LANG environment in my box , I have specified C as LANG environment.
# echo $LANG
C

# cat /var/lib/locales/supported.d/local
ja_JP.UTF-8 UTF-8
en_US.UTF-8 UTF-8

change the LANG environment to en_US.UTF-8 from C
# export LANG=en_US.UTF-8

try again. Okay.
# lxc-create -t ubuntu -n ubuntu-cn1

lxc-create: No config file specified, using the default config /etc/lxc/default.conf
Checking cache download in /var/cache/lxc/raring/rootfs-amd64 ...
Copy /var/cache/lxc/raring/rootfs-amd64 to /var/lib/lxc/ubuntu-cn1/rootfs ...
Copying rootfs to /var/lib/lxc/ubuntu-cn1/rootfs ...
Generating locales...
 en_US.UTF-8... done
Generation complete.

##
# The default user is 'ubuntu' with password 'ubuntu'!
# Use the 'sudo' command to run tasks as root in the container.
##

'ubuntu' template installed
'ubuntu-cn1' created

start the container.
# lxc-list
WARNING: lxc-list is deprecated, please use lxc-ls --fancy.
        This symlink will be dropped in LXC 1.0.

NAME        STATE    IPV4  IPV6  AUTOSTART
------------------------------------------
ubuntu-cn1  STOPPED  -     -     NO

# lxc-start -n ubuntu-cn1
<4>init: ureadahead main process (6) terminated with status 5
<4>init: udev-fallback-graphics main process (56) terminated with status 1
<4>init: console-font main process (80) terminated with status 1
<4>init: setvtrgb main process (92) terminated with status 1
<4>init: console-setup main process (97) terminated with status 1
<30>udevd[130]: starting version 175
<4>init: failsafe main process (147) killed by TERM signal


Ubuntu 13.04 ubuntu-cn1 console

ubuntu-cn1 login:

root@ubuntu-cn1:~# tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Ubuntu 13.04"

root@ubuntu-cn1:~# uname -ri
3.8.0-25-generic x86_64

The building time of the next container is very fast, because my box has already cached.
# time lxc-create -t ubuntu -n ubuntu-cn2

lxc-create: No config file specified, using the default config /etc/lxc/default.conf
Checking cache download in /var/cache/lxc/raring/rootfs-amd64 ...
Copy /var/cache/lxc/raring/rootfs-amd64 to /var/lib/lxc/ubuntu-cn2/rootfs ...
Copying rootfs to /var/lib/lxc/ubuntu-cn2/rootfs ...
Generating locales...
 ja_JP.UTF-8... up-to-date
Generation complete.

##
# The default user is 'ubuntu' with password 'ubuntu'!
# Use the 'sudo' command to run tasks as root in the container.
##

'ubuntu' template installed
'ubuntu-cn2' created

real    0m5.033s
user    0m3.144s
sys     0m2.404s