Preface
Two methods for provisioning containers.
Single Container Provisioning
- Creates a single containerd container
- Can enable IPv6 networking for a containerd container after
containerd-ipv6is configured during installation - Supports x86_64 and ARM64 architecture servers
IPv6 network mode
When the host has only an SLAAC-assigned public /64, containerd-ipv6 uses a host-route-disjoint ULA network with NAT66. In that mode, independent_ipv6=y enables IPv6 egress only; it does not allocate an Internet-reachable public /128.
Download Script
shell
curl -sSLO https://raw.githubusercontent.com/oneclickvirt/containerd/main/scripts/onecontainerd.sh
chmod +x onecontainerd.sh1
2
2
Example
Supported variables for running:
bash
./onecontainerd.sh <name> <cpu> <memory_mb> <password> <sshport> <startport> <endport> [independent_ipv6:y/n] [system] [disk_gb]1
Currently supported system values:
- debian
- ubuntu
- alpine
- almalinux
- rockylinux
- openeuler
Default is debian if not specified.
shell
./onecontainerd.sh ct1 1 512 MyPassword 25000 34975 35000 n debian 01
Example container information:
| Attribute | Value |
|---|---|
| Container name | ct1 |
| SSH username | root |
| SSH password | MyPassword |
| CPU cores | 1 |
| Memory | 512MB |
| SSH port | 25000 |
| External/internal port range | 34975 to 35000 |
| System | debian |
| Enable IPv6 egress (NAT66) | N |
| Disk size | Unlimited |
Related Operations
List all containers
shell
nerdctl ps -a1
Enter container
shell
nerdctl exec -it ct1 bash1
Enter Alpine container
shell
nerdctl exec -it ct1 sh1
Type exit to leave the container.
Delete container
shell
nerdctl rm -f ct11
View container logs
shell
nerdctl logs ct11
Batch Container Provisioning
- Multiple runs inherit configuration and generate sequentially
- Auto-increments container name (ct1, ct2, ...), SSH port, and public ports
- Container information recorded to
ctlogfile - Recommended to run in screen to avoid SSH disconnection
Run
shell
curl -sSLO https://raw.githubusercontent.com/oneclickvirt/containerd/main/scripts/create_containerd.sh
chmod +x create_containerd.sh
./create_containerd.sh1
2
3
2
3
Query Batch Container Information
shell
cat ctlog1
Output format:
container_name ssh_port root_password cpu_cores memory_mb start_port end_port disk_gb1
One line per container.
Remove All Containers and Images
shell
nerdctl ps -aq | xargs -r nerdctl rm -f
nerdctl images -q | xargs -r nerdctl rmi -f
rm -rf ctlog1
2
3
2
3
Restart All Containers After Host Reboot
By default, containers are not configured to auto-restart. Run the following command to start all stopped containers:
shell
nerdctl ps -aq -f status=exited | xargs -r nerdctl start1
