author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Sun, 30 Dec 2018 14:08:23 +0200 | |
changeset 2319 | 3d50794717d5 |
parent 2317 | 897bb1696e5f |
child 2345 | cb168a3d27ec |
permissions | -rw-r--r-- |
2022
2feba0bbefd0
Create new container in LXC.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
1 |
.. -*- coding: utf-8; -*- |
2feba0bbefd0
Create new container in LXC.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
2 |
|
2feba0bbefd0
Create new container in LXC.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
3 |
===== |
2feba0bbefd0
Create new container in LXC.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
4 |
LXC |
2feba0bbefd0
Create new container in LXC.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
5 |
===== |
2feba0bbefd0
Create new container in LXC.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
6 |
.. contents:: |
2feba0bbefd0
Create new container in LXC.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
7 |
:local: |
2feba0bbefd0
Create new container in LXC.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
8 |
|
2317
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
9 |
LXC releases |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
10 |
============ |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
11 |
|
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
12 |
https://discuss.linuxcontainers.org/tags/release |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
13 |
Announces of LXC & LXD releases. |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
14 |
https://discuss.linuxcontainers.org/t/lxc-3-0-0-has-been-released/1449 |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
15 |
LXC 3.0.0 has been released. |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
16 |
|
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
17 |
Supported templates |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
18 |
=================== |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
19 |
|
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
20 |
https://github.com/lxc/lxc-templates |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
21 |
Old style template scripts for LXC (prefer distrobuilder). |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
22 |
https://github.com/lxc/distrobuilder |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
23 |
System container image builder for LXC and LXD. |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
24 |
https://brauner.github.io/2018/02/27/lxc-removes-legacy-template-build-system.html |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
25 |
Details about replacing template stripts. |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
26 |
|
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
27 |
Install LXC under Debian |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
28 |
======================== |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
29 |
:: |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
30 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
31 |
$ sudo apt-get install lxc |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
32 |
|
2316
7de68fce3e7d
Verify your host/kernel satisfy LXC requirements.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2023
diff
changeset
|
33 |
Verify your host/kernel satisfy LXC requirements:: |
7de68fce3e7d
Verify your host/kernel satisfy LXC requirements.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2023
diff
changeset
|
34 |
|
7de68fce3e7d
Verify your host/kernel satisfy LXC requirements.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2023
diff
changeset
|
35 |
$ sudo lxc-checkconfig |
7de68fce3e7d
Verify your host/kernel satisfy LXC requirements.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2023
diff
changeset
|
36 |
|
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
37 |
To make network bridge install supplement packages:: |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
38 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
39 |
$ sudo apt-get install bridge-utils dnsmasq |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
40 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
41 |
To bootstrap Debian dostro into container install:: |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
42 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
43 |
$ sudo apt-get install debootstrap |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
44 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
45 |
To bring up network bridge edir ``/etc/default/lxc-net``:: |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
46 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
47 |
USE_LXC_BRIDGE="true" |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
48 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
49 |
LXC_ADDR="192.168.99.1" |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
50 |
LXC_NETMASK="255.255.255.0" |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
51 |
LXC_NETWORK="192.168.99.1/24" |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
52 |
LXC_DHCP_RANGE="192.168.99.100,192.168.99.200" |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
53 |
LXC_DHCP_MAX="20" |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
54 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
55 |
and start service:: |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
56 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
57 |
$ sudo service lxc-net start |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
58 |
|
2022
2feba0bbefd0
Create new container in LXC.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
59 |
Create new container in LXC |
2feba0bbefd0
Create new container in LXC.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
60 |
=========================== |
2feba0bbefd0
Create new container in LXC.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
61 |
|
2317
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
62 |
Create container from template:: |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
63 |
|
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
64 |
$ sudo lxc-create -t $TMPL -n $NAME -- $EXTRA_ARGS |
2022
2feba0bbefd0
Create new container in LXC.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
65 |
|
2317
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
66 |
.. note:: |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
67 |
* ``-t`` defines distro name |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
68 |
* ``-n`` gives name for container for further referencing |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
69 |
* everything after ``--`` is passed to template script |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
70 |
|
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
71 |
Template name is based on file name from ``/usr/share/lxc/templates`` directory without ``lxc-`` |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
72 |
prefix. |
2022
2feba0bbefd0
Create new container in LXC.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
73 |
|
2317
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
74 |
List available templates with:: |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
75 |
|
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
76 |
$ ls -alh /usr/share/lxc/templates/ |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
77 |
|
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
78 |
Examples of container creation command:: |
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
79 |
|
2317
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
80 |
$ sudo lxc-create -t debian -n deb-sid -- -r sid --enable-non-free |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
81 |
$ sudo lxc-create -t debian -n deb-testing -- -r testing |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
82 |
$ sudo lxc-create -t debian -n deb-stable -- -r stable -a amd64 |
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
83 |
|
2317
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
84 |
$ sudo lxc-create -t alpine -n alpine-3.7 -- -r 3.7 |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
85 |
|
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
86 |
Each template has own options, which can be passed after ``--``. To get help on template specific |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
87 |
options run:: |
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
88 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
89 |
$ /usr/share/lxc/templates/lxc-ubuntu -h |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
90 |
$ /usr/share/lxc/templates/lxc-debian -h |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
91 |
$ /usr/share/lxc/templates/lxc-alpine -h |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
92 |
... |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
93 |
|
2317
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
94 |
For Debian in order to use another miror:: |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
95 |
|
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
96 |
$ MIRROR=http://httpredir.debian.org/debian sudo lxc-create -t debian -n debtest -- -r sid |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
97 |
|
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
98 |
Since LXC v3.0 sh-templates moved to separate project and only 4 are left supported:: |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
99 |
|
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
100 |
$ lxc-create my-busybox -t busybox |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
101 |
$ lxc-create my-x -t download |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
102 |
$ lxc-create c1 -t local -- --metadata /path/to/meta.tar.xz --fstree /path/to/rootfs.tar.xz |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
103 |
$ lxc-create c2 -t oci -- --url docker://alpine |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
104 |
|
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
105 |
Put ``veth`` network configuration into container config ``/var/lib/lxc/$NAME/config``:: |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
106 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
107 |
lxc.network.type = veth |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
108 |
lxc.network.flags = up |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
109 |
lxc.network.link = lxcbr0 |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
110 |
lxc.network.veth.pair = veth-stretch |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
111 |
lxc.network.name = veth-stretch |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
112 |
lxc.network.ipv4 = 192.168.99.12/24 |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
113 |
lxc.network.ipv4.gateway = 192.168.99.1 |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
114 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
115 |
Fix DNS resolution in container:: |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
116 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
117 |
$ echo nameserver 8.8.8.8 | sudo tee /var/lib/lxc/$NAME/rootfs/etc/resolv.conf |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
118 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
119 |
LXC Container management |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
120 |
======================== |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
121 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
122 |
List available VMs:: |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
123 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
124 |
$ sudo lxc-ls |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
125 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
126 |
Start VM:: |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
127 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
128 |
$ sudo lxc-start -n $NAME |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
129 |
|
2316
7de68fce3e7d
Verify your host/kernel satisfy LXC requirements.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2023
diff
changeset
|
130 |
Safely stop VM (honoring init system):: |
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
131 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
132 |
$ sudo lxc-halt -n $NAME |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
133 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
134 |
Urgently stop VM:: |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
135 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
136 |
$ sudo lxc-stop -n $NAME |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
137 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
138 |
Mark container to start on boot in ``/var/lib/lxc/$NAME/config``:: |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
139 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
140 |
lxc.start.auto = 1 |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
141 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
142 |
Link containers in non standard location to take them in account:: |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
143 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
144 |
$ ln -s /opt/lxc/$NAME /var/lib/lxc/$NAME |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
145 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
146 |
Run command in rinning container:: |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
147 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
148 |
$ sudo lxc-attach -n $NAME-get update |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
149 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
150 |
Making snapshot |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
151 |
=============== |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
152 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
153 |
See ``lxc-snapshot(1)``. |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
154 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
155 |
List of snapshots:: |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
156 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
157 |
$ sudo lxc-snapshot --list |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
158 |
$ sudo lxc-snapshot -n $NAME --list |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
159 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
160 |
Make a snapshot:: |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
161 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
162 |
$ sudo lcx-halt -n $NAME |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
163 |
$ sudo lcx-snapshot -n $NAME |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
164 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
165 |
Restore from snapshot:: |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
166 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
167 |
$ sudo lcx-halt -n $NAME |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
168 |
$ sudo lcx-snapshot -n $NAME -r $SNAPNAME |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
169 |