userdoc:guest_lxc_container

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
userdoc:guest_lxc_container [2020/05/16 15:26]
abelbeck [Add Command via a Container]
userdoc:guest_lxc_container [2020/05/31 15:09]
abelbeck [Quick Start Guide]
Line 22: Line 22:
   lxc-attach debian10   lxc-attach debian10
     passwd     passwd
 +    apt update
     apt install openssh-server iputils-ping curl     apt install openssh-server iputils-ping curl
     ...     ...
Line 79: Line 80:
 # Container specific configuration # Container specific configuration
 lxc.tty.max = 0 lxc.tty.max = 0
 +#lxc.cgroup.memory.limit_in_bytes = 1024M
 +#lxc.cgroup.cpuset.cpus = 1,3
 lxc.rootfs.path = dir:/var/lib/lxc/debian10/rootfs lxc.rootfs.path = dir:/var/lib/lxc/debian10/rootfs
 lxc.uts.name = debian10 lxc.uts.name = debian10
Line 130: Line 133:
 ===== Destroy All Containers ===== ===== Destroy All Containers =====
  
-If you want disable all LXC container support, or start fresh, from the CLI:+If you want to disable all LXC container support, or start fresh, from the CLI:
  
 !!Warning ->!!  This action is not undoable, All LXC containers and download caches will be deleted! !!Warning ->!!  This action is not undoable, All LXC containers and download caches will be deleted!
Line 163: Line 166:
 Pi-hole is a perfect example to use with AstLinux within a LXC.  Begin as with the "Quick Start Guide" but use the name ''pi-hole''. Pi-hole is a perfect example to use with AstLinux within a LXC.  Begin as with the "Quick Start Guide" but use the name ''pi-hole''.
  
-__Enable Pi-hole LXC:__ +First, it is assumed the ''lxcbr0'' interface is setup per the above **Quick Start Guide** -> Enable LXC Support.
-\\ +
- +
-  * Define ''LXC_BRIDGE0'' in ''user.conf'' using a physical or VLAN interface +
-  * Assign ''lxcbr0'' to an internal interface in the **Network tab** +
-  * Reboot+
  
 Then from the CLI: Then from the CLI:
Line 178: Line 176:
   lxc-attach pi-hole   lxc-attach pi-hole
     passwd     passwd
 +    apt update
     apt install openssh-server iputils-ping curl     apt install openssh-server iputils-ping curl
     ...     ...
Line 215: Line 214:
 ===== Command via a Container ===== ===== Command via a Container =====
  
-There are occasions where a command might be useful within AstLinux, but since it uses python, golang, etc. or is just large in comparison to the 50 MB size of the AstLinux image.  A LXC container can be a handy tool to add such a command.+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.  A LXC container can be a handy tool to add such a command.
  
-Below is an example how to add the ''lynx'' command line web browser.+Below is an example how to add the ''lynx'' command line web browser.  The ''lynx'' container only runs when needed.
  
 First, it is assumed the ''lxcbr0'' interface is setup per the above **Quick Start Guide** -> Enable LXC Support. First, it is assumed the ''lxcbr0'' interface is setup per the above **Quick Start Guide** -> Enable LXC Support.
Line 228: Line 227:
  
   lxc-attach lynx   lxc-attach lynx
 +    apt update
     apt install lynx ca-certificates fping     apt install lynx ca-certificates fping
     exit     exit
  
-Next, stop the ''lynx' container and keep it from automatically starting.+Next, stop the ''lynx'' container and keep it from automatically starting.
  
   lxc-stop lynx   lxc-stop lynx
Line 255: Line 255:
      
   printf "Waiting for container network to become active... "   printf "Waiting for container network to become active... "
-  lxc-attach lynx -u $rand_uid -- fping -q -r15 8.8.4.4+  lxc-attach lynx -u $rand_uid -- fping -q -r15 $ping_ip
   printf "OK\n"   printf "OK\n"
      
Line 266: Line 266:
   exit 0   exit 0
  
 +!!Tip ->!! If you edit ''/var/lib/lxc/lynx/config'' and assign a manual IP address, the container starts very quickly, whereas using DHCP it takes 4-6 seconds to establish the network.
 +
 +Test it!
 +
 +  /mnt/kd/bin/lynx https://www.astlinux-project.org
  
 \\  \\ 
Line 277: Line 282:
 lxc.cgroup.memory.limit_in_bytes = 512M lxc.cgroup.memory.limit_in_bytes = 512M
 #lxc.cgroup.cpu.shares = 256 #lxc.cgroup.cpu.shares = 256
-lxc.cgroup.cpuset.cpus = 1+# Define which actual cores (e.g. 0 to 3) are allowed to use - comma separated (it's NOT the count of cores!) 
 +lxc.cgroup.cpuset.cpus = 1,3
 </code> </code>
  
 \\  \\ 
  • userdoc/guest_lxc_container.txt
  • Last modified: 2023/06/15 09:03
  • by abelbeck