From 66cccbea0a4e7347290cfd804136b2677708f08e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Marchal?= Date: Sun, 27 Oct 2019 13:39:44 +0100 Subject: [PATCH] populate the tips for lxc --- lxc_tips | 6 ------ lxc_tips.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 6 deletions(-) delete mode 100644 lxc_tips create mode 100644 lxc_tips.md diff --git a/lxc_tips b/lxc_tips deleted file mode 100644 index 3abea80..0000000 --- a/lxc_tips +++ /dev/null @@ -1,6 +0,0 @@ -# lxc launch [distribution] [name] -# eg: lxc launch images:debian/10 - -# lxc list - -# lxc exec [repository] [command] diff --git a/lxc_tips.md b/lxc_tips.md new file mode 100644 index 0000000..ab36960 --- /dev/null +++ b/lxc_tips.md @@ -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 .` \ No newline at end of file