Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
userdoc:guest_lxc_container [2020/05/24 17:12] mkeuter [Optional] |
userdoc:guest_lxc_container [2025/01/09 03:26] (current) mkeuter |
||
---|---|---|---|
Line 16: | Line 16: | ||
Then from the CLI: | Then from the CLI: | ||
- | lxc-create -t download -n debian10 | + | lxc-create -t download -n debian12 |
service lxc init | service lxc init | ||
- | lxc-attach | + | lxc-attach |
passwd | passwd | ||
+ | apt update | ||
apt install openssh-server iputils-ping curl | apt install openssh-server iputils-ping curl | ||
... | ... | ||
Line 34: | Line 35: | ||
service lxc stop | service lxc stop | ||
- | lxc-destroy | + | lxc-destroy |
If you don't want to re-enable LXC in the near future: | If you don't want to re-enable LXC in the near future: | ||
Line 49: | Line 50: | ||
LXC_BRIDGE0=" | LXC_BRIDGE0=" | ||
- | !!Tip ->!! If you have multiple LAN interfaces defined in the Network tab, assign '' | + | !!Tip ->!! If you have multiple LAN interfaces defined in the Network tab, assign '' |
!!Tip ->!! If you run out of physical interfaces to assign to the bridge, create a VLAN, for example: | !!Tip ->!! If you run out of physical interfaces to assign to the bridge, create a VLAN, for example: | ||
Line 79: | Line 80: | ||
# Container specific configuration | # Container specific configuration | ||
lxc.tty.max = 0 | lxc.tty.max = 0 | ||
+ | # | ||
+ | # | ||
lxc.rootfs.path = dir:/ | lxc.rootfs.path = dir:/ | ||
lxc.uts.name = debian10 | lxc.uts.name = debian10 | ||
Line 143: | Line 146: | ||
===== Recommended Base Installs ===== | ===== Recommended Base Installs ===== | ||
- | lxc-create -t download -n debian10 | + | lxc-create -t download -n debian12 |
| | ||
- | lxc-create -t download -n debian9 | + | lxc-create -t download -n debian11 |
| | ||
- | lxc-create -t download -n ubuntu18 | + | lxc-create -t download -n debian10 |
- | + | ||
- | lxc-create -t download -n centos8 -- -d centos -r 8 -a amd64 --no-validate | + | |
- | + | ||
- | lxc-create -t download -n centos7 -- -d centos -r 7 -a amd64 --no-validate | + | |
Typical base installs use less than 1 GB of disk space. | Typical base installs use less than 1 GB of disk space. | ||
- | |||
- | \\ | ||
- | ===== Pi-hole Container Example ===== | ||
- | |||
- | The [[https:// | ||
- | |||
- | Pi-hole is a perfect example to use with AstLinux within a LXC. Begin as with the "Quick Start Guide" but use the name '' | ||
- | |||
- | First, it is assumed the '' | ||
- | |||
- | Then from the CLI: | ||
- | |||
- | lxc-create -t download -n pi-hole -- -d debian -r buster -a amd64 --no-validate | ||
- | |||
- | service lxc init | ||
- | |||
- | lxc-attach pi-hole | ||
- | passwd | ||
- | apt install openssh-server iputils-ping curl | ||
- | ... | ||
- | exit | ||
- | |||
- | !!Tip ->!! Optionally you may want to also... | ||
- | apt install sudo nano | ||
- | |||
- | !!Tip ->!! Set '' | ||
- | |||
- | \\ | ||
- | __Install Pi-hole:__ | ||
- | \\ | ||
- | |||
- | Either with '' | ||
- | |||
- | curl -sSL https:// | ||
- | # Comment out the "set -e" in pihole.sh, then | ||
- | bash pihole.sh | ||
- | |||
- | Follow the dialogs and answer the questions. | ||
- | |||
- | Change Pi-hole WebGUI password: | ||
- | |||
- | / | ||
- | |||
- | \\ | ||
- | !!Tip ->!! If '' | ||
- | |||
- | apt remove lighttpd | ||
- | bash pihole.sh | ||
- | # choose " | ||
- | | ||
- | The Pi-hole LXC container uses about 40-50 MB of RAM. | ||
- | |||
- | \\ | ||
- | ===== Command via a Container ===== | ||
- | |||
- | There are occasions where a command might be useful within AstLinux, but it may use python, golang, etc. or is just large in comparison to the 50 MB size of the AstLinux image. | ||
- | |||
- | Below is an example how to add the '' | ||
- | |||
- | First, it is assumed the '' | ||
- | |||
- | Then from the CLI: | ||
- | |||
- | lxc-create -t download -n lynx -- -d debian -r buster -a amd64 --no-validate | ||
- | |||
- | service lxc restart | ||
- | |||
- | lxc-attach lynx | ||
- | apt install lynx ca-certificates fping | ||
- | exit | ||
- | |||
- | Next, stop the '' | ||
- | |||
- | lxc-stop lynx | ||
- | sed -i ' | ||
- | |||
- | Finally, create a wrapper script to start/stop the container and issue a command. | ||
- | |||
- | Place this script at ''/ | ||
- | #!/bin/sh | ||
- | ## | ||
- | ## lynx wrapper for LXC Debian 10 container | ||
- | ## | ||
- | | ||
- | ## generate a random uid | ||
- | rand_uid=$((RANDOM % 4999 + 95000)) | ||
- | | ||
- | ## Destination IP to test when container network is active | ||
- | ping_ip=" | ||
- | | ||
- | trap ' | ||
- | | ||
- | lxc-start lynx | ||
- | | ||
- | printf " | ||
- | lxc-attach lynx -u $rand_uid -- fping -q -r15 $ping_ip | ||
- | printf " | ||
- | | ||
- | lxc-attach lynx -u $rand_uid -- lynx " | ||
- | | ||
- | lxc-stop lynx | ||
- | | ||
- | trap - INT TERM EXIT | ||
- | | ||
- | exit 0 | ||
- | |||
- | !!Tip ->!! If you edit ''/ | ||
- | |||
- | Test it! | ||
- | |||
- | / | ||
\\ | \\ | ||
Line 277: | Line 164: | ||
lxc.cgroup.memory.limit_in_bytes = 512M | lxc.cgroup.memory.limit_in_bytes = 512M | ||
# | # | ||
- | # define | + | # Define |
lxc.cgroup.cpuset.cpus = 1,3 | lxc.cgroup.cpuset.cpus = 1,3 | ||
</ | </ | ||
\\ | \\ |