<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=JasonD</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=JasonD"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/JasonD"/>
	<updated>2026-04-30T13:56:32Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=LXC&amp;diff=10019</id>
		<title>LXC</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=LXC&amp;diff=10019"/>
		<updated>2014-06-14T16:19:31Z</updated>

		<summary type="html">&lt;p&gt;JasonD: /* Installation */ Added lxc-templates to installs.  No templates without it.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://lxc.sourceforge.net/ Linux Containers (LXC)] provides containers similar BSD Jails, Linux VServer and Solaris Zones. It gives the impression of virtualization, but shares the kernel and resources with the &amp;quot;host&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
Install the required packages:&lt;br /&gt;
{{Cmd|apk add lxc lxc-templates bridge}}&lt;br /&gt;
&lt;br /&gt;
== Prepare network on host ==&lt;br /&gt;
Set up a [[bridge]] on the host. Example &#039;&#039;/etc/network/interfaces&#039;&#039;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
auto br0&lt;br /&gt;
iface br0 inet dhcp&lt;br /&gt;
    bridge-ports eth0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a network configuration template for the guests, &#039;&#039;/etc/lxc/lxc.conf&#039;&#039;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lxc.network.type = veth&lt;br /&gt;
lxc.network.link = br0&lt;br /&gt;
lxc.network.flags = up&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create a guest ==&lt;br /&gt;
&lt;br /&gt;
=== Alpine Template ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lxc-create -n guest1 -f /etc/lxc/lxc.conf -t alpine}}&lt;br /&gt;
&lt;br /&gt;
This will create a &#039;&#039;/var/lib/lxc/guest1&#039;&#039; directory with a &#039;&#039;config&#039;&#039; file and a &#039;&#039;rootfs&#039;&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Note that by default alpine template &#039;&#039;&#039;does not have networking service on&#039;&#039;&#039;, you will need to add it using lxc-console&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If running on x86_64 architecture, it is possible to create a 32bit guest:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lxc-create -n guest1 -f /etc/lxc/lxc.conf -t alpine -- --arch x86}}&lt;br /&gt;
&lt;br /&gt;
=== Debian template ===&lt;br /&gt;
&lt;br /&gt;
In order to create a debian template container you will need to install some packages:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add debootstrap rsync}}&lt;br /&gt;
&lt;br /&gt;
Also you will need to turn off some grsecurity chroot options otherwise the debootstrap will fail:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_caps&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_chroot&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_mount&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_mknod&lt;br /&gt;
echo 0 &amp;gt; /proc/sys/kernel/grsecurity/chroot_deny_chmod&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Please remember to turn them back on, or just simply reboot the system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now you can run:&lt;br /&gt;
{{Cmd|SUITE{{=}}wheezy lxc-create -n guest1 -f /etc/lxc/lxc.conf -t debian}}&lt;br /&gt;
&lt;br /&gt;
== Starting/Stopping the guest ==&lt;br /&gt;
Create a symlink to the &#039;&#039;/etc/init.d/lxc&#039;&#039; script for your guest.&lt;br /&gt;
{{Cmd|ln -s lxc /etc/init.d/lxc.guest1}}&lt;br /&gt;
&lt;br /&gt;
You can start your guest with:&lt;br /&gt;
{{Cmd|/etc/init.d/lxc.guest1 start}}&lt;br /&gt;
&lt;br /&gt;
Stop it with:&lt;br /&gt;
{{Cmd|/etc/init.d/lxc.guest1 stop}}&lt;br /&gt;
&lt;br /&gt;
Make it autostart on boot up with:&lt;br /&gt;
{{Cmd| rc-update add lxc.guest1}}&lt;br /&gt;
&lt;br /&gt;
== Connecting to the guest ==&lt;br /&gt;
By default sshd is not installed, so you will have to connect to a virtual console. This is done with:&lt;br /&gt;
{{Cmd|lxc-console -n guest1}}&lt;br /&gt;
&lt;br /&gt;
To disconnect from it, press {{key|Ctrl}}+{{key|a}} {{key|q}}&lt;br /&gt;
&lt;br /&gt;
== Deleting a guest ==&lt;br /&gt;
Make sure the guest is stopped and run:&lt;br /&gt;
{{Cmd|lxc-destroy -n guest1}}&lt;br /&gt;
This will erase everything, without asking any questions. It is equivalent to: {{Cmd|rm -r /var/lib/lxc/guest1}}&lt;br /&gt;
&lt;br /&gt;
== Advanced ==&lt;br /&gt;
&lt;br /&gt;
=== Using static IP ===&lt;br /&gt;
&lt;br /&gt;
If you&#039;re using static IP, you need to configure this properly on guest&#039;s /etc/network/interfaces. To stay on the above example, modify &#039;&#039;/var/lib/lxc/guest1/rootfs/etc/network/interfaces&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
from&lt;br /&gt;
&lt;br /&gt;
 #auto lo&lt;br /&gt;
     iface lo inet loopback&lt;br /&gt;
 auto eth0&lt;br /&gt;
     iface eth0 inet &#039;&#039;&#039;dhcp&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
to &lt;br /&gt;
&lt;br /&gt;
 #auto lo&lt;br /&gt;
     iface lo inet loopback&lt;br /&gt;
 auto eth0&lt;br /&gt;
     iface eth0 inet &#039;&#039;&#039;static&#039;&#039;&#039;&lt;br /&gt;
     address &amp;lt;lxc-container-ip&amp;gt;   # IP which the lxc container should use&lt;br /&gt;
     gateway &amp;lt;gateway-ip&amp;gt;         # IP of gateway to use, mostly same as on lxc-host&lt;br /&gt;
     netmask &amp;lt;netmask&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== mem and swap ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|vim /boot/extlinux.conf}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&lt;br /&gt;
  APPEND initrd{{=}}initramfs-3.10.13-1-grsec root{{=}}UUID{{=}}7cd8789f-5659-40f8-9548-ae8f89c918ab modules{{=}}sd-mod,usb-storage,ext4 quiet cgroup_enable{{=}}memory swapaccount{{=}}1&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== checkconfig ===&lt;br /&gt;
{{Cmd|lxc-checkconfig}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&lt;br /&gt;
Kernel configuration not found at /proc/config.gz; searching...&lt;br /&gt;
Kernel configuration found at /boot/config-3.10.13-1-grsec&lt;br /&gt;
--- Namespaces ---&lt;br /&gt;
Namespaces: enabled&lt;br /&gt;
Utsname namespace: enabled&lt;br /&gt;
Ipc namespace: enabled&lt;br /&gt;
Pid namespace: enabled&lt;br /&gt;
User namespace: missing&lt;br /&gt;
Network namespace: enabled&lt;br /&gt;
Multiple /dev/pts instances: enabled&lt;br /&gt;
&lt;br /&gt;
--- Control groups ---&lt;br /&gt;
Cgroup: enabled&lt;br /&gt;
Cgroup clone_children flag: enabled&lt;br /&gt;
Cgroup device: enabled&lt;br /&gt;
Cgroup sched: enabled&lt;br /&gt;
Cgroup cpu account: enabled&lt;br /&gt;
Cgroup memory controller: missing&lt;br /&gt;
Cgroup cpuset: enabled&lt;br /&gt;
&lt;br /&gt;
--- Misc ---&lt;br /&gt;
Veth pair device: enabled&lt;br /&gt;
Macvlan: enabled&lt;br /&gt;
Vlan: enabled&lt;br /&gt;
File capabilities: enabled&lt;br /&gt;
&lt;br /&gt;
Note : Before booting a new kernel, you can check its configuration&lt;br /&gt;
usage : CONFIG{{=}}/path/to/config /usr/bin/lxc-checkconfig&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== VirtualBox ===&lt;br /&gt;
&lt;br /&gt;
In order for network to work on containers you need to set &amp;quot;Promiscuous Mode&amp;quot; to &amp;quot;Allow All&amp;quot; in VirtualBox settings for the network adapter.&lt;br /&gt;
&lt;br /&gt;
[[File:VirtualBoxNetworkAdapter.jpg]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Virtualization]]&lt;br /&gt;
&lt;br /&gt;
== LXC 1.0 Additional information ==&lt;br /&gt;
&lt;br /&gt;
Some info regarding new features in LXC 1.0&lt;br /&gt;
 &lt;br /&gt;
https://www.stgraber.org/2013/12/20/lxc-1-0-blog-post-series/&lt;/div&gt;</summary>
		<author><name>JasonD</name></author>
	</entry>
</feed>