populate the tips for lxc

This commit is contained in:
Théo Marchal 2019-10-27 13:39:44 +01:00
parent e3565d0b03
commit 66cccbea0a
2 changed files with 50 additions and 6 deletions

View File

@ -1,6 +0,0 @@
# lxc launch [distribution] [name]
# eg: lxc launch images:debian/10
# lxc list
# lxc exec [repository] [command]

50
lxc_tips.md Normal file
View File

@ -0,0 +1,50 @@
# LXC tips
## Create a container
* `$ lxc launch [distribution] [name]`
* **example:** `$ lxc launch images:debian/10 debian-container`
## List existing containers
* `$ 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 |
+-------------+---------+----------------------+---------------------------+------------+-----------+
```
## Change state
* Start a container: `$ lxc start [container]`
* Stop a container: `$ lxc stop [container]`
## Access a container
* `$ lxc exec [repository] [command]`
* **example:** `$ lxc exec test bash`
## Snapshots
* Create a snapshot: `$ lxc snapshot [container] [snapshot_name]`
* **example:** `$ lxc snapshot test base_state`
* Restore a snapshot: `$ lxc restore [container] [snapshot_name]`
* **example:** `$ lxc restore test 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)
* From a container: `$ lxc file pull [container][/files/to/copy] [destination/path]`
* **example:** `$ lxc file pull test/root/files .`