Running LXC Container in Incus
Images available for creating LXC Containers
A portion of the available system parameters are shown here for your reference:
- debian10, debian11, debian12, debian13
- ubuntu18, ubuntu20, ubuntu22
- centos8, centos9 (actually opened out of the Stream version)
- alpine3.15, alpine3.16, alpine3.17, alpine3.18
- openwrt21, openwrt22, fedora37, fedora38, fedora39
- rockylinux8, rockylinux9, oracle8, oracle9
- oracle7, centos7 (CGroupV1 needs to be enabled in GRUB or it won't start.)
- kali, archlinux
- Note that the combination of lowercase letters + numbers or only lowercase letters, try it yourself, if the search is not the system will automatically exit the script
- The version number can be with English decimal point, in order to adapt to the alpine version number has been supported.
- If you can't open it, it may be that the hard disk is not big enough or it doesn't fit the host, try it by yourself.
- The images currently in use are triple filtered and prioritized: self-hosted、official-hosted、opsmaru
- A complete list of supported systems for self-compiling images: x86_64_all_images.txt and arm64_all_images.txt
TIP
The version number has ended the long-term maintenance of the general no longer have an official mirror, temporarily did not find the archive address of the historical mirror, if you find welcome to leave a message I will add support!
Generate only one NAT container
- Generate only one NAT container, with customizable restrictions on all content.
Download script
Downloading the boot script is NOT REQUIRED, if you have used the command to install incus with one click, the corresponding boot script will be downloaded automatically, so you don't need to download the script again.
Command:
curl -L https://raw.githubusercontent.com/oneclickvirt/incus/main/scripts/buildct.sh -o buildct.sh && chmod +x buildct.sh && dos2unix buildct.shUsage
. /buildct.sh name Cpu_num Memory_size Hard_disk_size SSH_port Extranet_start_port Extranet_stop_port Download_speed Upload_speed Whether_IPV6_is_enabled(Y or N) System(leave blank for debian11)Memory is in MB, disk size in GB, and download/upload speeds in Mbit. For IPv6, you can provide Y or N, or leave it empty (default: disabled).
If both external start port and external stop port are set to 0, no port-range mapping is created and only SSH is mapped. These fields cannot be empty.
Custom container systems are supported. If left empty, debian11 is used by default. Use the format system + version.
Example
Example container configuration:
| Attribute | Value |
|---|---|
| Container Name | test |
| Username for SSH Login | root |
| Password for SSH Login | Randomly generated |
| Number of CPU Cores | 1 |
| Memory Size | 256MB |
| Disk Size | 2G |
| Range of Internal and External Port Mapping | 20002 to 20025 |
| Upload Bandwidth | 500Mbit |
| Download Bandwidth | 500Mbit |
| Automatically Set External IPv6 Address | No |
| Operating System | Debian 11 |
./buildct.sh test 1 256 2 20001 20002 20025 500 500 N debian11If you need to see the information, run
cat ct_name_change_meFor example, the information for the query example is
cat testIf you already created a test container and want to do batch generation, delete the test container first.
Delete Test Container
incus stop test
incus delete test
rm -rf test
rm -rf test_v6
ls2
3
4
5
Normal version batch generation
Batch Profile:
- 1 core 256MB RAM 1GB hard disk limited to 300Mbit bandwidth
- With 1 SSH port, 24 extranet ports
- Default memory and hard disk size
TIP
If incus commands run normally, proceed with initialization. It is recommended to run this in a screen session because runtime depends on host resources and the number of containers.
Execute the following command to load the boot script
Command:
curl -L https://raw.githubusercontent.com/oneclickvirt/incus/main/scripts/init.sh -o init.sh && chmod +x init.sh && dos2unix init.shThe following command opens 10 containers with prefix tj.
./init.sh tj 10If path issues occur when running init.sh, prepend sudo and run it from the root directory.
Bulk generation of pure SSH port versions
Batch Profile:
- 1 core 128MB RAM 1GB hard disk limited to 300Mbit bandwidth
- Only one SSH port
- Unable to mount warp
TIP
If incus commands run normally, proceed with initialization. Use a screen session to avoid interruption; runtime depends on host resources and container count.
Load boot script
Command:
curl -L https://raw.githubusercontent.com/oneclickvirt/incus/main/scripts/least.sh -o least.sh && chmod +x least.sh && dos2unix least.shThe last command below opens 10 containers with prefix tj.
./least.sh tj 10If path issues occur when running least.sh, prepend sudo and run it from the root directory.
Custom Batch Generation of Versions
- Customizable memory and hard disk sizes
- It's also fine if you have manually executed the above batch generation before; the configuration inherits without overwriting
If you need to batch-generate containers multiple times, you can use the following:
Command:
curl -L https://github.com/oneclickvirt/incus/raw/main/scripts/add_more.sh -o add_more.sh && chmod +x add_more.sh && bash add_more.shThis script can be run multiple times. It appends new containers while inheriting previous configuration, with customizable memory and disk size.
View Batch Container Information
After creation, container information is written to a log file in the current directory in this format:
container_1_Name Password SSH_Port Public_Port_Start Public_Port_End
container_2_Name Password SSH_Port Public_Port_Start Public_Port_End2
To view it, print the log file from the current directory:
cat logWARNING
Do not use containers created by this script as production environments. Incus containers do not support kernel replacement, DD reinstall flows, BBR toggling, and similar host-level changes.
Common Incus Commands
View all containers:
incus listView details of a specific container:
incus info container_nameStart a specific container:
incus start container_nameStop a specific container:
incus stop container_nameDelete a specific container:
incus delete -f container_nameEnter the container's shell:
incus exec container_name /bin/bashTIP
Instead of /bin/bash, you can use /bin/sh in alpine, which is /bin/bash on regular systems.
To exit, type ```exit`` and enter.
Delete all incus containers
incus list -c n --format csv | xargs -I {} incus delete -f {}Perform deletion of useless logs within a container
sudo apt-get autoremove
sudo apt-get clean
sudo find /var/log -type f -delete
sudo find /var/tmp -type f -delete
sudo find /tmp -type f -delete
sudo find /var/cache/apt/archives -type f -delete2
3
4
5
6
Update all commands related to the above one-click scripts
Delete the original configuration script
rm -rf /usr/local/bin/ssh_sh.sh
rm -rf /usr/local/bin/config.sh
rm -rf /usr/local/bin/ssh_bash.sh
rm -rf /usr/local/bin/check-dns.sh
rm -rf /root/ssh_sh.sh
rm -rf /root/config.sh
rm -rf /root/ssh_bash.sh
rm -rf /root/buildct.sh
rm -rf /root/add_more.sh
rm -rf /root/build_ipv6_network.sh2
3
4
5
6
7
8
9
10
Download back the relevant configuration scripts for the new version
curl -sSL https://raw.githubusercontent.com/oneclickvirt/incus/main/scripts/check-dns.sh -o /usr/local/bin/check-dns.sh && chmod +x /usr/local/bin/check-dns.sh
curl -sSL https://raw.githubusercontent.com/oneclickvirt/incus/main/scripts/config.sh -o /usr/local/bin/config.sh && chmod +x /usr/local/bin/config.sh
curl -sSL https://raw.githubusercontent.com/oneclickvirt/incus/main/scripts/ssh_bash.sh -o /usr/local/bin/ssh_bash.sh && chmod +x /usr/local/bin/ssh_bash.sh
curl -sSL https://raw.githubusercontent.com/oneclickvirt/incus/main/scripts/ssh_sh.sh -o /usr/local/bin/ssh_sh.sh && chmod +x /usr/local/bin/ssh_sh.sh
curl -sSL https://raw.githubusercontent.com/oneclickvirt/incus/main/scripts/build_ipv6_network.sh -o /root/build_ipv6_network.sh && chmod +x /root/build_ipv6_network.sh
curl -sSL https://raw.githubusercontent.com/oneclickvirt/incus/main/scripts/buildct.sh -o /root/buildct.sh && chmod +x /root/buildct.sh2
3
4
5
6
Just download the other one-click scripts yourself.
