Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| userdoc:guest_lxc_container_command [2020/06/01 02:19] – created abelbeck | userdoc:guest_lxc_container_command [2020/06/01 15:50] (current) – abelbeck | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Command via a Container ====== | ====== 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. | ||
| + | |||
| + | **Resource Usage:** (minimum) | ||
| + | * Memory: 100 MB | ||
| + | * Storage: 0.4 GB | ||
| + | \\ | ||
| + | |||
| + | 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 update | ||
| + | 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! | ||
| + | |||
| + | / | ||
| + | |||
| + | \\ | ||
| + | !!Related Info ->!! **[[userdoc: | ||