lost and found ( for me ? )

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

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.