precisions about privileged containers and clarified some examples
This commit is contained in:
parent
353901b5f6
commit
fffaa20d24
42
lxc_tips.md
42
lxc_tips.md
@ -3,7 +3,7 @@
|
||||
## Create a container
|
||||
|
||||
* `$ lxc launch [distribution] [name]`
|
||||
* **example:** `$ lxc launch images:debian/10 debian-container`
|
||||
* **example:** `$ lxc launch images:debian/10 test-container`
|
||||
|
||||
## List available distribution images
|
||||
|
||||
@ -14,19 +14,19 @@
|
||||
* `$ lxc list`
|
||||
|
||||
```
|
||||
+-------------+---------+----------------------+---------------------------+------------+-----------+
|
||||
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
|
||||
+-------------+---------+----------------------+---------------------------+------------+-----------+
|
||||
| alpine | STOPPED | | | PERSISTENT | 1 |
|
||||
+-------------+---------+----------------------+---------------------------+------------+-----------+
|
||||
| debian | STOPPED | | | PERSISTENT | 0 |
|
||||
+-------------+---------+----------------------+---------------------------+------------+-----------+
|
||||
| ubuntu | STOPPED | | | PERSISTENT | 3 |
|
||||
+-------------+---------+----------------------+---------------------------+------------+-----------+
|
||||
| minimal | RUNNING | 10.10.10.10 (eth0) | fd80::0000 (eth0) | PERSISTENT | 0 |
|
||||
+-------------+---------+----------------------+---------------------------+------------+-----------+
|
||||
| test | STOPPED | | | PERSISTENT | 0 |
|
||||
+-------------+---------+----------------------+---------------------------+------------+-----------+
|
||||
+----------------+---------+----------------------+---------------------------+------------+-----------+
|
||||
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
|
||||
+----------------+---------+----------------------+---------------------------+------------+-----------+
|
||||
| alpine | STOPPED | | | PERSISTENT | 1 |
|
||||
+----------------+---------+----------------------+---------------------------+------------+-----------+
|
||||
| debian | STOPPED | | | PERSISTENT | 0 |
|
||||
+----------------+---------+----------------------+---------------------------+------------+-----------+
|
||||
| ubuntu | STOPPED | | | PERSISTENT | 3 |
|
||||
+----------------+---------+----------------------+---------------------------+------------+-----------+
|
||||
| minimal | RUNNING | 10.10.10.10 (eth0) | fd80::0000 (eth0) | PERSISTENT | 0 |
|
||||
+----------------+---------+----------------------+---------------------------+------------+-----------+
|
||||
| test-container | STOPPED | | | PERSISTENT | 0 |
|
||||
+----------------+---------+----------------------+---------------------------+------------+-----------+
|
||||
```
|
||||
|
||||
## Change state
|
||||
@ -37,21 +37,21 @@
|
||||
## Access a container
|
||||
|
||||
* `$ lxc exec [repository] [command]`
|
||||
* **example:** `$ lxc exec test bash`
|
||||
* **example:** `$ lxc exec test-container bash`
|
||||
|
||||
## Snapshots
|
||||
|
||||
* Create a snapshot: `$ lxc snapshot [container] [snapshot_name]`
|
||||
* **example:** `$ lxc snapshot test base_state`
|
||||
* **example:** `$ lxc snapshot test-container base_state`
|
||||
* Restore a snapshot: `$ lxc restore [container] [snapshot_name]`
|
||||
* **example:** `$ lxc restore test base_state`
|
||||
* **example:** `$ lxc restore test-container base_state`
|
||||
|
||||
## Copy files
|
||||
|
||||
* To a container: `$ lxc file push [/local/files/to/copy] [container]/[destination/path]`
|
||||
* **example:** `$ lxc file push -r /home/user/files test/root` (add `-r` to copy a folder)
|
||||
* **example:** `$ lxc file push -r /home/user/files test-container/root` (add `-r` to copy a folder)
|
||||
* From a container: `$ lxc file pull [container][/files/to/copy] [destination/path]`
|
||||
* **example:** `$ lxc file pull test/root/files .`
|
||||
* **example:** `$ lxc file pull test-container/root/files .`
|
||||
|
||||
## Privileged containers
|
||||
|
||||
@ -60,7 +60,7 @@ This feature is only available when LXD is installed.
|
||||
* When creating a container: `$ lxc launch [distribution] [name] -c security.privileged=true`
|
||||
* Please note that this parameter apparently cannot be changed later.
|
||||
|
||||
When a container is privileged, we can share folders from the host to the container.
|
||||
When a container is privileged, we can share folders from the host to the container, in a **read-write** manner. We can still add a shared folder with unprivileged containers, but they will be **read-only** (chowned at nobody:nobody).
|
||||
|
||||
* Adding a shared folder: `$ lxc config device add [container] [share_name] disk source=[/host/path/] path=[/container/path]`
|
||||
* **example:** `$ lxc config device add test home_dir disk source=/home/$USER path=/home/ubuntu`
|
||||
* **example:** `$ lxc config device add test-container home_dir disk source=/home/$USER path=/home/ubuntu`
|
Loading…
Reference in New Issue
Block a user