author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Tue, 03 Nov 2020 19:31:40 +0200 | |
changeset 2446 | ad63d001b5f4 |
parent 2349 | d750ee7ed18f |
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 |
|
2349 | 9 |
LXC docs |
10 |
======== |
|
11 |
||
12 |
https://linuxcontainers.org/lxc/getting-started/ |
|
13 |
Upstream "Getting Started". |
|
14 |
https://help.ubuntu.com/lts/serverguide/lxc.html |
|
15 |
Ubuntu Server Guide » Virtualization » LXC |
|
16 |
||
2317
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
17 |
LXC releases |
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://discuss.linuxcontainers.org/tags/release |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
21 |
Announces of LXC & LXD releases. |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
22 |
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
|
23 |
LXC 3.0.0 has been released. |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
24 |
|
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
25 |
Supported templates |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
26 |
=================== |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
27 |
|
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
28 |
https://github.com/lxc/lxc-templates |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
29 |
Old style template scripts for LXC (prefer distrobuilder). |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
30 |
https://github.com/lxc/distrobuilder |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
31 |
System container image builder for LXC and LXD. |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
32 |
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
|
33 |
Details about replacing template stripts. |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
34 |
|
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
35 |
Install LXC under Debian |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
36 |
======================== |
2345
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
37 |
|
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
38 |
Installation:: |
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
39 |
|
2345
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
40 |
$ sudo apt install lxc |
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
41 |
|
2345
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
42 |
Verify that your host/kernel satisfies LXC requirements:: |
2316
7de68fce3e7d
Verify your host/kernel satisfy LXC requirements.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2023
diff
changeset
|
43 |
|
7de68fce3e7d
Verify your host/kernel satisfy LXC requirements.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2023
diff
changeset
|
44 |
$ sudo lxc-checkconfig |
7de68fce3e7d
Verify your host/kernel satisfy LXC requirements.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2023
diff
changeset
|
45 |
|
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
46 |
To make network bridge install supplement packages:: |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
47 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
48 |
$ sudo apt-get install bridge-utils dnsmasq |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
49 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
50 |
To bootstrap Debian dostro into container install:: |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
51 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
52 |
$ sudo apt-get install debootstrap |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
53 |
|
2345
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
54 |
To bring up network bridge create or edit ``/etc/default/lxc-net``:: |
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
55 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
56 |
USE_LXC_BRIDGE="true" |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
57 |
|
2345
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
58 |
LXC_ADDR="10.0.0.1" |
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
59 |
LXC_NETMASK="255.255.255.0" |
2345
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
60 |
LXC_NETWORK="10.0.0.0/24" |
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
61 |
LXC_DHCP_RANGE="10.0.0.2,10.0.0.254" |
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
62 |
LXC_DHCP_MAX="253" |
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
63 |
LXC_DHCP_CONFILE="" |
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
64 |
LXC_DOMAIN="" |
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
65 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
66 |
and start service:: |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
67 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
68 |
$ sudo service lxc-net start |
2345
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
69 |
$ sudo systemctl restart lxc-net.service |
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
70 |
|
2348
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
71 |
Project file layout |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
72 |
=================== |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
73 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
74 |
* ``/usr/share/lxc/templates`` is list of templates. |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
75 |
* ``/var/cache/lxc`` is cache for downloaded images. |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
76 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
77 |
* ``~/.local/share/lxc`` container storage. |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
78 |
* ``~/.config/lxc`` container configs. |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
79 |
* ``~/.cache/lxc`` is cache for unprivileged downloded images. |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
80 |
* ``~/.local/share/lxcsnaps`` is storage for unprivileged snapshots. |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
81 |
|
2022
2feba0bbefd0
Create new container in LXC.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
82 |
Create new container in LXC |
2feba0bbefd0
Create new container in LXC.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
83 |
=========================== |
2feba0bbefd0
Create new container in LXC.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
84 |
|
2317
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
85 |
Create container from template:: |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
86 |
|
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
87 |
$ sudo lxc-create -t $TMPL -n $NAME -- $EXTRA_ARGS |
2022
2feba0bbefd0
Create new container in LXC.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
88 |
|
2317
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
89 |
.. note:: |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
90 |
* ``-t`` defines distro name |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
91 |
* ``-n`` gives name for container for further referencing |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
92 |
* everything after ``--`` is passed to template script |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
93 |
|
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
94 |
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
|
95 |
prefix. |
2022
2feba0bbefd0
Create new container in LXC.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
96 |
|
2317
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
97 |
List available templates with:: |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
98 |
|
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
99 |
$ ls -alh /usr/share/lxc/templates/ |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
100 |
|
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
101 |
Examples of container creation command:: |
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
102 |
|
2317
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
103 |
$ 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
|
104 |
$ sudo lxc-create -t debian -n deb-testing -- -r testing |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
105 |
$ 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
|
106 |
|
2317
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
107 |
$ 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
|
108 |
|
2346
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
109 |
Examples of destroying container:: |
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
110 |
|
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
111 |
$ sudo lxc-destroy --name $NAME |
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
112 |
|
2317
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
113 |
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
|
114 |
options run:: |
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
115 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
116 |
$ /usr/share/lxc/templates/lxc-ubuntu -h |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
117 |
$ /usr/share/lxc/templates/lxc-debian -h |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
118 |
$ /usr/share/lxc/templates/lxc-alpine -h |
2345
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
119 |
$ /usr/share/lxc/templates/lxc-download -h |
2023
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 |
|
2317
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
122 |
For Debian in order to use another miror:: |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
123 |
|
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
124 |
$ 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
|
125 |
|
2345
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
126 |
List of prebuild containers: |
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
127 |
|
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
128 |
* Visit http://images.linuxcontainers.org/ (default storage of LXC project). |
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
129 |
* Run ``/usr/share/lxc/templates/lxc-download --list`` |
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
130 |
|
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
131 |
Creating container by downloading pre-built image:: |
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
132 |
|
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
133 |
sudo lxc-create -t download -n alpine-edge -- -d alpine -r edge -a amd64 |
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
134 |
sudo lxc-create -t download -n debian-sid -- -d debian -r sid -a amd64 |
2346
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
135 |
sudo lxc-create -t download -n ubuntu-bio -- --dist ubuntu --release bionic --arch amd64 |
2345
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
136 |
|
2317
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
137 |
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
|
138 |
|
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
139 |
$ lxc-create my-busybox -t busybox |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
140 |
$ lxc-create my-x -t download |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
141 |
$ 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
|
142 |
$ lxc-create c2 -t oci -- --url docker://alpine |
897bb1696e5f
LXC releases. Supported templates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2316
diff
changeset
|
143 |
|
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
144 |
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
|
145 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
146 |
lxc.network.type = veth |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
147 |
lxc.network.flags = up |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
148 |
lxc.network.link = lxcbr0 |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
149 |
lxc.network.veth.pair = veth-stretch |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
150 |
lxc.network.name = veth-stretch |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
151 |
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
|
152 |
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
|
153 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
154 |
Fix DNS resolution in container:: |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
155 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
156 |
$ 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
|
157 |
|
2348
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
158 |
Creating unpriviliged containers |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
159 |
================================ |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
160 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
161 |
Check if user has assigned ids for namespaces:: |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
162 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
163 |
$ cat /etc/subuid |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
164 |
vagrant:100000:65536 |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
165 |
$ cat /etc/subgid |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
166 |
vagrant:100000:65536 |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
167 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
168 |
If not assign ranges with:: |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
169 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
170 |
sudo usermod -v 100000-165536 -w 100000-165536 vagrant |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
171 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
172 |
or:: |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
173 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
174 |
sudo usermod -add-subuids 100000-165536 vagrant |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
175 |
sudo usermod -add-subgids 100000-165536 vagrant |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
176 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
177 |
Create local config:: |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
178 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
179 |
mkdir -p ~/.config/lxc |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
180 |
cat <<EOF >~/.config/lxc/default.conf |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
181 |
lxc.idmap = u 0 100000 65536 |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
182 |
lxc.idmap = g 0 100000 65536 |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
183 |
lxc.network.type = veth |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
184 |
lxc.network.link = lxcbr0 |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
185 |
EOF |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
186 |
echo "$USER veth lxcbr0 2" | sudo tee -a /etc/lxc/lxc-usernet |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
187 |
|
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
188 |
LXC Container management |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
189 |
======================== |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
190 |
|
2346
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
191 |
List available containers:: |
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
192 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
193 |
$ sudo lxc-ls |
2348
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
194 |
$ sudo lxc-ls -f |
2346
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
195 |
$ sudo lxc-ls --fancy |
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
196 |
|
2346
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
197 |
Show details about container:: |
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
198 |
|
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
199 |
$ sudo lxc-info --name $NAME |
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
200 |
|
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
201 |
Start container:: |
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
202 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
203 |
$ sudo lxc-start -n $NAME |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
204 |
|
2346
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
205 |
Show boot process output during container start with ``-F``:: |
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
206 |
|
2346
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
207 |
$ sudo lxc-start -n $NAME -F |
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
208 |
$ sudo lxc-start -n $NAME --foreground |
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
209 |
|
2346
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
210 |
Safely stop container (by default sends ``SIGPWR`` signal to container ``init`` process and waits 60 |
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
211 |
sec and then send ``SIGKILL``):: |
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
212 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
213 |
$ sudo lxc-stop -n $NAME |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
214 |
|
2346
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
215 |
To signal reboot (by default sends ``SIGINT`` signal to container ``init`` process):: |
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
216 |
|
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
217 |
$ sudo lxc-stop -n $NAME -r |
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
218 |
$ sudo lxc-stop -n $NAME --reboot |
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
219 |
|
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
220 |
Urgently stop container (kills all processes):: |
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
221 |
|
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
222 |
$ sudo lxc-stop -n $NAME -k |
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
223 |
$ sudo lxc-stop -n $NAME --kill |
f644e8d27cd2
updated commands to 2.x/3.x syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2345
diff
changeset
|
224 |
|
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
225 |
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
|
226 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
227 |
lxc.start.auto = 1 |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
228 |
|
2348
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
229 |
Other autostart params:: |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
230 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
231 |
lxc.start.delay = 15 # delay in seconds |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
232 |
lxc.start.order = 50 # higher value means starts earlier |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
233 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
234 |
Limit memory usage:: |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
235 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
236 |
lxc.cgroup.memory.limit_in_bytes = 256M |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
237 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
238 |
Apply memory limit on fly:: |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
239 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
240 |
sudo lxc-cgroup -n $NAME memory.limit_in_bytes 100M |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
241 |
|
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
242 |
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
|
243 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
244 |
$ 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
|
245 |
|
2348
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
246 |
Show container status/into:: |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
247 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
248 |
$ sudo lxc-info -n $NAME |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
249 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
250 |
Print just state:: |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
251 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
252 |
$ sudo lxc-info -n $NAME -s |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
253 |
$ sudo lxc-info -n $NAME --state |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
254 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
255 |
Print just pid:: |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
256 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
257 |
$ sudo lxc-info -n $NAME -p |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
258 |
$ sudo lxc-info -n $NAME --pid |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
259 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
260 |
Print just IP addresses:: |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
261 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
262 |
$ sudo lxc-info -n $NAME -i |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
263 |
$ sudo lxc-info -n $NAME --ips |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
264 |
|
2345
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
265 |
Run command in running container:: |
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
266 |
|
2345
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
267 |
$ sudo lxc-attach -n $NAME |
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
268 |
$ sudo lxc-attach -n $NAME bash |
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
269 |
$ sudo lxc-attach -n $NAME -- ls -a |
cb168a3d27ec
Creating container by downloading pre-built image.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2317
diff
changeset
|
270 |
$ sudo lxc-attach -n $NAME -- apk list |
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
271 |
|
2348
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
272 |
Open session in console (attaches container tty process to current terminal, prompt for |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
273 |
user/password):: |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
274 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
275 |
$ sudo lxc-console -n $NAME |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
276 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
277 |
Freeze/unfreeze:: |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
278 |
|
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
279 |
$ sudo lxc-freeze -n $NAME |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
280 |
$ sudo lxc-unfreeze -n $NAME |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
281 |
|
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
282 |
Making snapshot |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
283 |
=============== |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
284 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
285 |
See ``lxc-snapshot(1)``. |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
286 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
287 |
List of snapshots:: |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
288 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
289 |
$ sudo lxc-snapshot --list |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
290 |
$ sudo lxc-snapshot -n $NAME --list |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
291 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
292 |
Make a snapshot:: |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
293 |
|
2348
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
294 |
$ sudo lxc-halt -n $NAME |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
295 |
$ sudo lxc-snapshot -n $NAME |
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
296 |
|
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
297 |
Restore from snapshot:: |
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
298 |
|
2348
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
299 |
$ sudo lxc-halt -n $NAME |
fbfaded9734e
Creating unpriviliged containers.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2346
diff
changeset
|
300 |
$ sudo lxc-snapshot -n $NAME -r $SNAPNAME |
2023
72b82c178018
Install LXC under Debian. LXC Container management.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2022
diff
changeset
|
301 |