# HG changeset patch # User Oleksandr Gavenko # Date 1548551503 -7200 # Node ID cb168a3d27eca063cf057fe217890a0287ea7fc9 # Parent 8370ecc93eec2bc8eda44befc6f8dc346ec96537 Creating container by downloading pre-built image. diff -r 8370ecc93eec -r cb168a3d27ec lxc.rst --- a/lxc.rst Sun Jan 27 03:11:05 2019 +0200 +++ b/lxc.rst Sun Jan 27 03:11:43 2019 +0200 @@ -26,11 +26,12 @@ Install LXC under Debian ======================== -:: + +Installation:: - $ sudo apt-get install lxc + $ sudo apt install lxc -Verify your host/kernel satisfy LXC requirements:: +Verify that your host/kernel satisfies LXC requirements:: $ sudo lxc-checkconfig @@ -42,19 +43,22 @@ $ sudo apt-get install debootstrap -To bring up network bridge edir ``/etc/default/lxc-net``:: +To bring up network bridge create or edit ``/etc/default/lxc-net``:: USE_LXC_BRIDGE="true" - LXC_ADDR="192.168.99.1" + LXC_ADDR="10.0.0.1" LXC_NETMASK="255.255.255.0" - LXC_NETWORK="192.168.99.1/24" - LXC_DHCP_RANGE="192.168.99.100,192.168.99.200" - LXC_DHCP_MAX="20" + LXC_NETWORK="10.0.0.0/24" + LXC_DHCP_RANGE="10.0.0.2,10.0.0.254" + LXC_DHCP_MAX="253" + LXC_DHCP_CONFILE="" + LXC_DOMAIN="" and start service:: $ sudo service lxc-net start + $ sudo systemctl restart lxc-net.service Create new container in LXC =========================== @@ -89,12 +93,23 @@ $ /usr/share/lxc/templates/lxc-ubuntu -h $ /usr/share/lxc/templates/lxc-debian -h $ /usr/share/lxc/templates/lxc-alpine -h + $ /usr/share/lxc/templates/lxc-download -h ... For Debian in order to use another miror:: $ MIRROR=http://httpredir.debian.org/debian sudo lxc-create -t debian -n debtest -- -r sid +List of prebuild containers: + +* Visit http://images.linuxcontainers.org/ (default storage of LXC project). +* Run ``/usr/share/lxc/templates/lxc-download --list`` + +Creating container by downloading pre-built image:: + + sudo lxc-create -t download -n alpine-edge -- -d alpine -r edge -a amd64 + sudo lxc-create -t download -n debian-sid -- -d debian -r sid -a amd64 + Since LXC v3.0 sh-templates moved to separate project and only 4 are left supported:: $ lxc-create my-busybox -t busybox @@ -143,9 +158,12 @@ $ ln -s /opt/lxc/$NAME /var/lib/lxc/$NAME -Run command in rinning container:: +Run command in running container:: - $ sudo lxc-attach -n $NAME-get update + $ sudo lxc-attach -n $NAME + $ sudo lxc-attach -n $NAME bash + $ sudo lxc-attach -n $NAME -- ls -a + $ sudo lxc-attach -n $NAME -- apk list Making snapshot ===============