Today I will show you how to use openSUSE kiwi to build your own docker images, openvz images, lxc images, iso Linux distro and so on.
You need set your opensuse 13.2 desktop or server on, it's meaning that you need to install opensuse 13.2 x86-64 or i586, or opensuse 13.1.
You can build it with your vmware or other virtual boxes.
ok, let's get started.
一, Docker images
Turn your openSUSE on and type next commands in terminal.
$ zypper in kiwi kiwi-doc
we have installed kiwi and kiwi examples on your machine.
find kiwi examples
$ cd /usr/share/doc/packages/kiwi/examples
that is the examples path
you will find suse-12..2, suse-12.3, suse-13.1, suse-13.2 files, we need to use suse-13.1
go to suse-13.1, you must see some files like "suse-docker-container", "suse-ec2-guest" and so on.
create a docker image and build it for a minimal image
$ kiwi -p suse-docker-container --root /tmp/docker (you can add "linux32" before kiwi if you want to build a 32 bit image in opensuse x86-64 environment)
this command means prapare a docker live files on the path of "/tmp/docker", you can change /tmp/docker to your favorite path.
we need to go to /usr/lib and delete "locale" file except en_US and en_US_UTF8. locale file size about 100Mb, so you will got 204Mb docker image.
build download files to a docker image
$ cd /tmp
$ kiwi --build docker --destdir docker-image
a docker image file you will find at /tmp/docker-image, it is a suse-13.1-docker-1.0.0.tar.xz like files. it's about 45Mb or less.
二, OpenVZ images
how to build a openvz image, it is very similar to build a docker image, openvz and docker are both lxc virtual kind, you can use docker image as your openvz image.
but if you want to add some packages like postfix, iptables, openssh, fail2ban and so on, I will tell you how to do next, next will be a more advanced than build a docker images.
the same, we also need to go to suse-13.1 examples, and go to suse-docker-container, edit it and change something we need to use next.
$ cd /usr/share/doc/packages/kiwi/examples/suse-13.1
$ cp -ar suse-docker-container suse-openvz-container
$ cd suse-openvz-container && vim config.xml
we will edit config.xml for openvz packages
change the second line to "" , if you use opensuse-12.3, you need to change schemaversion="6.1" to 5.1.
and we can add some packages in to this file.
you will find and add after it.
save it and build a openvz image
$ cd ..
$ kiwi -p suse-openvz-container --root /tmp/openvz --set-repo http://mirrors.ustc.edu.cn/opensuse/distribution/13.1/repo/oss/
--set-repo means you can selelt a fast mirror
go to /tmp/openvz//usr/lib/locale, delete all the files except en_US and en_US_UTF8.
build a openvz image
$ kiwi --build /tmp/openvz --destdir openvz-image
ok, you will find a suse-openvz---.tar.xz file in /tmp/openvz-image, yourself build openvz image is done, you can use it and cp it to /vz/template/cache.