Here's how to create CentOS6 containers under Ubuntu host
Install lxc, lxc-templates and yum on Ubuntu, which is required to run CentOS container.
# tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Ubuntu 14.04.3 LTS"
# uname -ri
3.19.0-33-generic x86_64
# apt-get install lxc lxc-templates yum
|
template files are located at /usr/share/lxc/templates directory.
# dpkg -L lxc-templates | grep 'templates/'
/usr/share/lxc/templates/lxc-gentoo
/usr/share/lxc/templates/lxc-centos
# ls /usr/share/lxc/templates/
lxc-alpine lxc-archlinux lxc-centos lxc-debian lxc-fedora lxc-openmandriva lxc-oracle lxc-sshd lxc-ubuntu-cloud
lxc-altlinux lxc-busybox lxc-cirros lxc-download lxc-gentoo lxc-opensuse lxc-plamo lxc-ubuntu
|
create a CentOS container.
# /usr/share/lxc/templates/lxc-centos -n centos01 -R 6.7
Host CPE ID from /etc/os-release:
Checking cache download in /var/cache/lxc/centos/x86_64/6.7/rootfs ...
Downloading centos minimal ...
Fixing rpmdb location ...
Download complete.
Copy /var/cache/lxc/centos/x86_64/6.7/rootfs to /var/lib/lxc/centos01/rootfs ...
Copying rootfs to /var/lib/lxc/centos01/rootfs ...
Storing root password in '/var/lib/lxc/centos01/tmp_root_pass'
Expiring password for user root.
passwd: Success
Container rootfs and config have been created.
Edit the config file to check/enable networking setup.
The temporary root password is stored in:
'/var/lib/lxc/centos01/tmp_root_pass'
The root password is set up as expired and will require it to be changed
at first login, which you should do as soon as possible. If you lose the
root password or wish to change it without starting the container, you
can change it from the host by running the following command (which will
also reset the expired flag):
chroot /var/lib/lxc/centos01/rootfs passwd
|
change container’s root password, if you would like.
# chroot /var/lib/lxc/centos01/rootfs passwd
|
or
You can also create a CentOS container via lxc-create with ‘-t’ opton.
# lxc-create -t centos -n centos02
Host CPE ID from /etc/os-release:
This is not a CentOS or Redhat host and release is missing, defaulting to 6 use -R|--release to specify release
Checking cache download in /var/cache/lxc/centos/x86_64/6/rootfs ...
Cache found. Updating...
Loaded plugins: fastestmirror
|
run the container
# lxc-start -n centos02 –d
|
access to the container.
# lxc-attach -n centos02
|
[root@centos02 ~]# cat /etc/centos-release
CentOS release 6.7 (Final)
[root@centos02 ~]# uname -a
Linux centos02 3.19.0-33-generic #38~14.04.1-Ubuntu SMP Fri Nov 6 18:17:28 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
|
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.