103 lines
2.7 KiB
Markdown
103 lines
2.7 KiB
Markdown
|
|
# Quick Start: Using Template as Base for All LXCs
|
||
|
|
|
||
|
|
## Step 1: Choose Your Base Template
|
||
|
|
|
||
|
|
Run the template script to see available options:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/addon/all-templates.sh)"
|
||
|
|
```
|
||
|
|
|
||
|
|
Or list available templates directly:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
pveam available | grep -E "debian|ubuntu|alpine"
|
||
|
|
```
|
||
|
|
|
||
|
|
## Step 2: Download the Template (Once)
|
||
|
|
|
||
|
|
For example, Debian 12:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
pveam download local debian-12-standard_12.2-1_amd64.tar.zst
|
||
|
|
```
|
||
|
|
|
||
|
|
This downloads the template to your local storage. You only need to do this once.
|
||
|
|
|
||
|
|
## Step 3: Set Template Variable
|
||
|
|
|
||
|
|
Create or update your configuration file with:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# In your deployment config file or .env
|
||
|
|
export CONTAINER_OS_TEMPLATE="local:vztmpl/debian-12-standard_12.2-1_amd64.tar.zst"
|
||
|
|
```
|
||
|
|
|
||
|
|
## Step 4: Deploy Multiple Containers
|
||
|
|
|
||
|
|
Now you can deploy as many containers as needed from this single template:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# Container 1 - Web Server
|
||
|
|
pct create 100 "$CONTAINER_OS_TEMPLATE" \
|
||
|
|
--hostname web1 \
|
||
|
|
--memory 2048 \
|
||
|
|
--cores 2 \
|
||
|
|
--rootfs local-lvm:20 \
|
||
|
|
--net0 name=eth0,bridge=vmbr0,ip=dhcp \
|
||
|
|
--unprivileged 1
|
||
|
|
|
||
|
|
# Container 2 - Database
|
||
|
|
pct create 101 "$CONTAINER_OS_TEMPLATE" \
|
||
|
|
--hostname db1 \
|
||
|
|
--memory 4096 \
|
||
|
|
--cores 4 \
|
||
|
|
--rootfs local-lvm:50 \
|
||
|
|
--net0 name=eth0,bridge=vmbr0,ip=dhcp \
|
||
|
|
--unprivileged 1
|
||
|
|
|
||
|
|
# Container 3 - App Server
|
||
|
|
pct create 102 "$CONTAINER_OS_TEMPLATE" \
|
||
|
|
--hostname app1 \
|
||
|
|
--memory 2048 \
|
||
|
|
--cores 2 \
|
||
|
|
--rootfs local-lvm:30 \
|
||
|
|
--net0 name=eth0,bridge=vmbr0,ip=dhcp \
|
||
|
|
--unprivileged 1
|
||
|
|
```
|
||
|
|
|
||
|
|
## Step 5: Start Containers
|
||
|
|
|
||
|
|
```bash
|
||
|
|
pct start 100
|
||
|
|
pct start 101
|
||
|
|
pct start 102
|
||
|
|
```
|
||
|
|
|
||
|
|
## Benefits
|
||
|
|
|
||
|
|
✅ **One template, unlimited containers** - Download once, deploy many times
|
||
|
|
✅ **Storage efficient** - Template is reused, only differences are stored
|
||
|
|
✅ **Consistent base** - All containers start from the same clean OS
|
||
|
|
✅ **Easy updates** - Update template, all new containers get updates
|
||
|
|
✅ **Fast deployment** - No need to download template for each container
|
||
|
|
|
||
|
|
## Your Current Setup
|
||
|
|
|
||
|
|
Your deployment scripts already use this pattern! Check:
|
||
|
|
- `smom-dbis-138-proxmox/scripts/deployment/deploy-services.sh`
|
||
|
|
- `smom-dbis-138-proxmox/config/proxmox.conf.example`
|
||
|
|
|
||
|
|
They use: `CONTAINER_OS_TEMPLATE="${CONTAINER_OS_TEMPLATE:-local:vztmpl/debian-12-standard_12.2-1_amd64.tar.zst}"`
|
||
|
|
|
||
|
|
This means:
|
||
|
|
- If `CONTAINER_OS_TEMPLATE` is set, use it
|
||
|
|
- Otherwise, default to Debian 12 standard template
|
||
|
|
|
||
|
|
## Next Steps
|
||
|
|
|
||
|
|
1. **Set your template** in your config file
|
||
|
|
2. **Download it once**: `pveam download local debian-12-standard_12.2-1_amd64.tar.zst`
|
||
|
|
3. **Deploy containers** using your deployment scripts - they'll automatically use the template!
|
||
|
|
|