Linux Container: Difference between revisions
No edit summary |
|||
Line 1: | Line 1: | ||
= Introduction | == Introduction == | ||
A Linux Container is an operating-system-level virtualization environment for running multiple isolated Linux systems on a single Linux control host ([https://en.wikipedia.org/wiki/LXC Wikipedia LXC]). It can be also defined as a lightweight VM but extremely fast and easy to deploy. | A Linux Container is an operating-system-level virtualization environment for running multiple isolated Linux systems on a single Linux control host ([https://en.wikipedia.org/wiki/LXC Wikipedia LXC]). It can be also defined as a lightweight VM but extremely fast and easy to deploy. | ||
Line 9: | Line 9: | ||
Linux Containers are introduced in Proxmox VE 4.0 and support the [[Storage_Model |Proxmox Storage Model]]. | Linux Containers are introduced in Proxmox VE 4.0 and support the [[Storage_Model |Proxmox Storage Model]]. | ||
= System requirements | == System requirements == | ||
*Proxmox VE 4.0 or higher | *Proxmox VE 4.0 or higher | ||
=Features= | == Features == | ||
*Support of local directories('''NOTE:not on ZFS use instead ZFSPoolPlugin'''), NFS, ZFS, LVM, Ceph and DRBD9 (other will/can follow) | *Support of local directories('''NOTE:not on ZFS use instead ZFSPoolPlugin'''), NFS, ZFS, LVM, Ceph and DRBD9 (other will/can follow) | ||
*manipulate disk size | *manipulate disk size | ||
Line 27: | Line 27: | ||
*Network support for VLAN, IPv4, IPv6 | *Network support for VLAN, IPv4, IPv6 | ||
=Supported OS= | == Supported OS == | ||
*Debian 6, 7, 8 | *Debian 6, 7, 8 | ||
*CentOS 6 | *CentOS 6 | ||
Line 34: | Line 34: | ||
Other OS are following step by step. | Other OS are following step by step. | ||
=Manage containers= | == Manage containers == | ||
Management can be done either via the web gui, or via command line tools | Management can be done either via the web gui, or via command line tools | ||
==Get a container template== | === Get a container template === | ||
All templates can be downloaded at the GUI.[[File:DownloadContainer.png|200px|thumb|rigth|DownloadContainer]] | All templates can be downloaded at the GUI.[[File:DownloadContainer.png|200px|thumb|rigth|DownloadContainer]] | ||
<b>NOTE: Only the supported OS work</b> | <b>NOTE: Only the supported OS work</b> | ||
Line 45: | Line 45: | ||
</pre> | </pre> | ||
==Create container== | === Create container === | ||
After you have downloaded a template, you can create a container based on it. | After you have downloaded a template, you can create a container based on it. | ||
[[File:Create CT.png|200px|thumb|rigth|Create CT]] | [[File:Create CT.png|200px|thumb|rigth|Create CT]] | ||
Line 59: | Line 59: | ||
</pre> | </pre> | ||
==Start container== | === Start container === | ||
There are two possibilities to start a container: | There are two possibilities to start a container: | ||
either on the GUI or on the command line [[File:Start_CT.png|200px|thumb|rigth|Start Container]] | either on the GUI or on the command line [[File:Start_CT.png|200px|thumb|rigth|Start Container]] | ||
Line 66: | Line 66: | ||
</pre> | </pre> | ||
==Stop container== | === Stop container === | ||
Stopping a container can be done in a similar way like starting a container. | Stopping a container can be done in a similar way like starting a container. | ||
[[File:Stop_CT.png|200px|thumb|rigth|Stop Container]] | [[File:Stop_CT.png|200px|thumb|rigth|Stop Container]] | ||
Line 73: | Line 73: | ||
</pre> | </pre> | ||
==Backup container== | === Backup container === | ||
The backup can be done in three different modes: snapshot, suspend and stopped. This mode options have only an effect if the container is running. | The backup can be done in three different modes: snapshot, suspend and stopped. This mode options have only an effect if the container is running. | ||
[[File:Backup_CT.png|200px|thumb|rigth|Backup Container]] | [[File:Backup_CT.png|200px|thumb|rigth|Backup Container]] | ||
Line 87: | Line 87: | ||
vzdump 100 -compress lzo -dumpdir /var/lib/vz/dump/ -mode snapshot -remove 0 | vzdump 100 -compress lzo -dumpdir /var/lib/vz/dump/ -mode snapshot -remove 0 | ||
==Restore container== | === Restore container === | ||
[[File:Restore CT.png|200px|thumb|rigth|Restore Container]] | [[File:Restore CT.png|200px|thumb|rigth|Restore Container]] | ||
It is easy and fast to restore a container. | It is easy and fast to restore a container. | ||
On the GUI it | On the GUI it was only possible to restore a container with the same VMID and if there is no VM with this VMID. In Proxmox VE 3+ it can be restored to any available VMID. | ||
If you need to change the VMID or override a VM you can use the command line tool pct. | If you need to change the VMID or override a VM you can use the command line tool pct. | ||
Line 98: | Line 98: | ||
pct restore 101 /var/lib/vz/dump/vzdump-lxc-100-2015_06_22-11_12_40.tar.lzo | pct restore 101 /var/lib/vz/dump/vzdump-lxc-100-2015_06_22-11_12_40.tar.lzo | ||
=Migrate container from OpenVZ to Linux container= | == Migrate container from OpenVZ to Linux container == | ||
Follow this howto: | Follow this howto: | ||
* [[Convert OpenVZ to LXC]] | * [[Convert OpenVZ to LXC]] | ||
=References= | == References == | ||
[https://en.wikipedia.org/wiki/LXC Wikipedia Linux Container] | * [https://en.wikipedia.org/wiki/LXC Wikipedia Linux Container] | ||
* [https://linuxcontainers.org/ Linux Container] | |||
* [https://github.com/lxc GIT Linux Container] | |||
[[Category:Installation]][[Category:Technology]][[Category:HOWTO]] | [[Category:Installation]][[Category:Technology]][[Category:HOWTO]] |
Revision as of 10:53, 27 October 2015
Introduction
A Linux Container is an operating-system-level virtualization environment for running multiple isolated Linux systems on a single Linux control host (Wikipedia LXC). It can be also defined as a lightweight VM but extremely fast and easy to deploy.
There is not much overhead and therefore it's the perfect solution for effective use of resources.
No extra kernel boot is necessary on startup resulting in a super fast boot.
Linux Containers are introduced in Proxmox VE 4.0 and support the Proxmox Storage Model.
System requirements
- Proxmox VE 4.0 or higher
Features
- Support of local directories(NOTE:not on ZFS use instead ZFSPoolPlugin), NFS, ZFS, LVM, Ceph and DRBD9 (other will/can follow)
- manipulate disk size
- snapshot, rollback, clone, linked clone (all these features need storage support)
- Kernel namespaces (ipc, uts, mount, pid, network and user)
- Apparmor profiles
- Seccomp policies
- Chroots (using pivot_root)
- Kernel capabilities
- CGroups (control groups)
- Migration
- Backup and restore
- Integrated firewall
- Network support for VLAN, IPv4, IPv6
Supported OS
- Debian 6, 7, 8
- CentOS 6
- Ubuntu 12.04, 14.04, 15.04
- Archlinux
Other OS are following step by step.
Manage containers
Management can be done either via the web gui, or via command line tools
Get a container template
All templates can be downloaded at the GUI.
NOTE: Only the supported OS work
If the containers are not yet visible use the following pve command to update the list.
pveam update
Create container
After you have downloaded a template, you can create a container based on it.
A GUI wizard will guide you through the creation process.
It is also possible to create a container with the pct command line tool. More details see manpages
pct create 104 /var/lib/vz/template/cache/debian-8.0-standard_8.0-1_amd64.tar.gz \ -description LXC -rootfs 4 -hostname pvecontainer01 -memory 1024 -nameserver 8.8.8.8 \ -net0 name=eth0,hwaddr=52:4A:5E:26:58:D8,ip=192.168.15.147/24,gw=192.168.15.1,bridge=vmbr0 \ -storage local -password changeme
Start container
There are two possibilities to start a container:
either on the GUI or on the command line
pct start 100
Stop container
Stopping a container can be done in a similar way like starting a container.
pct stop 100
Backup container
The backup can be done in three different modes: snapshot, suspend and stopped. This mode options have only an effect if the container is running.
Snapshot mode: this feature depends on the filesystem and so it must support snapshots. If snapshot mode is chosen but it's not supported by the filesystem the backup will be done in suspend mode.
Suspend mode: the container will be frozen during the time the backup is running. NOTE: Container is not running untill backup is done!
Stopped mode: the container will be turned off and restarted after backup.
The command line tool backing up Linux container is vzdump. For more information read vzdump manpage.
vzdump 100 -compress lzo -dumpdir /var/lib/vz/dump/ -mode snapshot -remove 0
Restore container
It is easy and fast to restore a container.
On the GUI it was only possible to restore a container with the same VMID and if there is no VM with this VMID. In Proxmox VE 3+ it can be restored to any available VMID.
If you need to change the VMID or override a VM you can use the command line tool pct.
For more information read the man page of pct.
pct restore 101 /var/lib/vz/dump/vzdump-lxc-100-2015_06_22-11_12_40.tar.lzo
Migrate container from OpenVZ to Linux container
Follow this howto: