Update install guide to use Unraid Container Builder with br0 dedicated IPs

Replace Docker Compose Manager steps with per-container Container Builder
setup. Each container (web, db, pma) gets its own fixed LAN IP via br0,
removing the need for port mapping. DB_HOST env var now points to the
database container's br0 IP instead of the internal Docker hostname.

https://claude.ai/code/session_015wpwmheufcxkBuXivrSHhd
This commit is contained in:
Claude
2026-02-28 22:10:32 +00:00
parent 83a6bd35c4
commit eafc11864f

217
README.md
View File

@@ -24,7 +24,7 @@
| `alwisp_db` | MySQL 8.0 | Database (internal only) |
| `alwisp_pma` | phpMyAdmin (optional) | DB admin UI on port 8080 |
All containers share a private `alwisp_net` bridge network. MySQL is never exposed to the internet — the web container reaches it via the internal hostname `db`. Data persists in a named Docker volume (`db_data`) and survives container restarts and rebuilds.
Each container is deployed individually through the Unraid Container Builder and connected via the `br0` bridge network, giving both the web container and the database container their own dedicated LAN IP addresses. The web container reaches the database by its fixed LAN IP. Data persists in a named Docker volume (`db_data`) and survives container restarts and rebuilds.
---
@@ -34,23 +34,14 @@ All containers share a private `alwisp_net` bridge network. MySQL is never expos
- Unraid 6.10 or later
- **Community Applications** plugin installed
- **Docker** enabled in Unraid settings (Settings → Docker → Enable Docker: Yes)
- **Docker** enabled (Settings → Docker → Enable Docker: Yes)
- **User Scripts** plugin (recommended, for scheduled tasks)
- A share to store the project files (e.g. `/mnt/user/appdata/alwisp`)
- `br0` enabled — your Unraid host NIC must be bridged (Settings → Network → Enable Bridging: Yes)
- Decide on **two free LAN IPs** before you start — one for the web container, one for the database. Example: `192.168.1.100` (web) and `192.168.1.101` (db). Reserve these in your router's DHCP settings so they are never auto-assigned.
---
### Step 1 Install the Compose Manager plugin
Unraid handles multi-container apps via the **Docker Compose Manager** plugin.
1. Open **Apps** (Community Applications)
2. Search for `Docker Compose Manager`
3. Click **Install** and let it complete
---
### Step 2 Clone the repository onto your Unraid share
### Step 1 Clone the repository onto your Unraid share
Open an Unraid terminal (**Tools → Terminal** or SSH in):
@@ -62,44 +53,85 @@ cd alwisp
---
### Step 3 Create your `.env` file
### Step 2 Build the Docker image
```bash
nano .env
```
Paste and fill in real values:
```env
DB_ROOT_PASS=your_secure_root_password
DB_NAME=alwisp
DB_USER=alwisp_user
DB_PASS=your_secure_db_password
```
Save with `Ctrl+O`, exit with `Ctrl+X`.
> **Important:** Never commit `.env` to git. It is already listed in `.gitignore`.
---
### Step 4 Add the project to Docker Compose Manager
1. In the Unraid web UI, go to the **Docker** tab
2. Click **Compose** (added by the plugin)
3. Click **Add New Stack**
4. Set the name: `alwisp`
5. Set the compose file path: `/mnt/user/appdata/alwisp/docker-compose.yml`
6. Click **Save**
7. Click **Start** to build and launch all containers
Alternatively, start directly from the terminal:
The web container uses a custom image built from the included `Dockerfile`. Build it once from the terminal — Unraid's Container Builder will reference it by name.
```bash
cd /mnt/user/appdata/alwisp
docker compose up -d --build
docker build -t alwisp_web:latest .
```
> After any code change to the `Dockerfile`, re-run this command and then restart the container from the Docker tab.
---
### Step 3 Add the Database container (alwisp_db)
1. In the Unraid web UI, go to the **Docker** tab
2. Click **Add Container**
3. Fill in the form:
| Field | Value |
|---|---|
| **Name** | `alwisp_db` |
| **Repository** | `mysql:8.0` |
| **Network Type** | `br0` |
| **Fixed IP** | `192.168.1.101` *(your reserved DB IP)* |
| **Restart Policy** | `Unless Stopped` |
4. Scroll to **Environment Variables** and add:
| Key | Value |
|---|---|
| `MYSQL_ROOT_PASSWORD` | *(strong root password)* |
| `MYSQL_DATABASE` | `alwisp` |
| `MYSQL_USER` | `alwisp_user` |
| `MYSQL_PASSWORD` | *(strong db password)* |
5. Scroll to **Path/Volume Mappings** and add:
| Container Path | Host Path | Access Mode |
|---|---|---|
| `/var/lib/mysql` | `/mnt/user/appdata/alwisp/db_data` | Read/Write |
| `/docker-entrypoint-initdb.d/init.sql` | `/mnt/user/appdata/alwisp/docker/mysql/init.sql` | Read Only |
6. Click **Apply** — Unraid pulls the MySQL image and starts the container
---
### Step 4 Add the Web container (alwisp_web)
1. Click **Add Container** again
2. Fill in the form:
| Field | Value |
|---|---|
| **Name** | `alwisp_web` |
| **Repository** | `alwisp_web:latest` *(the image you built in Step 2)* |
| **Network Type** | `br0` |
| **Fixed IP** | `192.168.1.100` *(your reserved web IP)* |
| **Restart Policy** | `Unless Stopped` |
3. Add **Environment Variables**:
| Key | Value |
|---|---|
| `DB_HOST` | `192.168.1.101` *(the DB container's br0 IP from Step 3)* |
| `DB_NAME` | `alwisp` |
| `DB_USER` | `alwisp_user` |
| `DB_PASS` | *(same password set in Step 3)* |
4. Add **Path/Volume Mappings**:
| Container Path | Host Path | Access Mode |
|---|---|---|
| `/var/www/html` | `/mnt/user/appdata/alwisp/www` | Read/Write |
| `/etc/apache2/sites-available/000-default.conf` | `/mnt/user/appdata/alwisp/docker/apache/000-default.conf` | Read Only |
| `/etc/apache2/ssl` | `/mnt/user/appdata/alwisp/docker/apache/ssl` | Read Only |
5. Click **Apply**
---
### Step 5 Verify containers are running
@@ -108,32 +140,54 @@ docker compose up -d --build
docker ps --filter name=alwisp
```
You should see `alwisp_web` and `alwisp_db` both with status `Up`.
Both `alwisp_web` and `alwisp_db` should show status `Up`.
Open a browser and navigate to your Unraid server's IP:
Navigate to the web container's dedicated IP in a browser:
```
http://<unraid-ip> → website
http://<unraid-ip>:8080 → phpMyAdmin (optional, see below)
http://192.168.1.100 → website (replace with your web IP)
```
To start phpMyAdmin for database administration:
```bash
docker compose --profile tools up -d
```
Because `br0` gives the container its own LAN IP, **no port mapping is needed** — it behaves like a separate device on your network.
---
### Step 6 Point a domain (optional)
### Step 6 Add phpMyAdmin (optional)
If you have a domain and are running **Nginx Proxy Manager** on Unraid:
For database administration, add a third container:
1. In Nginx Proxy Manager, add a **Proxy Host**
2. Forward hostname/IP: your Unraid server IP, port `80`
1. Click **Add Container**
2. Fill in:
| Field | Value |
|---|---|
| **Name** | `alwisp_pma` |
| **Repository** | `phpmyadmin:latest` |
| **Network Type** | `br0` |
| **Fixed IP** | `192.168.1.102` *(another free LAN IP)* |
3. Add **Environment Variables**:
| Key | Value |
|---|---|
| `PMA_HOST` | `192.168.1.101` *(DB container's br0 IP)* |
| `PMA_USER` | `alwisp_user` |
| `PMA_PASSWORD` | *(your db password)* |
4. Click **Apply**, then browse to `http://192.168.1.102`
---
### Step 7 Point a domain (optional)
Because the web container has a dedicated LAN IP, reverse proxy setup is straightforward:
**Using Nginx Proxy Manager on Unraid:**
1. Add a **Proxy Host** in Nginx Proxy Manager
2. Forward hostname/IP: `192.168.1.100` (the web container's br0 IP), port `80`
3. Enable SSL via Let's Encrypt
4. SSL certificate files can be bind-mounted into the container at `/etc/apache2/ssl/`
— the volume mount `./docker/apache/ssl` is already wired in `docker-compose.yml`
4. Drop your certificate files into `/mnt/user/appdata/alwisp/docker/apache/ssl/` — they are already mounted into the container
---
@@ -271,51 +325,48 @@ alwisp/
## Updating the Site
Because `./www` is bind-mounted directly into the container, **PHP and asset changes take effect immediately** — no rebuild needed.
Because `/mnt/user/appdata/alwisp/www` is bind-mounted directly into `alwisp_web`, **PHP and asset changes take effect immediately** — no rebuild or restart needed.
```bash
# Pull latest code
cd /mnt/user/appdata/alwisp
git pull origin main
# If Dockerfile or docker-compose.yml changed, rebuild:
docker compose up -d --build
# Rebuild only the web container without touching the database:
docker compose up -d --build web
# If the Dockerfile changed, rebuild the image and restart the web container:
docker build -t alwisp_web:latest /mnt/user/appdata/alwisp
docker restart alwisp_web
```
The database container (`alwisp_db`) is completely independent — updates to the site never affect it.
---
## Useful Commands
```bash
# Start all containers
docker compose up -d
# Rebuild the web image after Dockerfile changes
docker build -t alwisp_web:latest /mnt/user/appdata/alwisp
# Start with phpMyAdmin (admin tools profile)
docker compose --profile tools up -d
# Start / stop individual containers
docker start alwisp_web
docker stop alwisp_web
docker restart alwisp_web
# Stop all containers
docker compose down
docker start alwisp_db
docker stop alwisp_db
# View live logs (all containers)
docker compose logs -f
# View logs for one container
docker compose logs -f web
# Restart just the web container
docker compose restart web
# View live logs
docker logs -f alwisp_web
docker logs -f alwisp_db
# Open a shell inside the web container
docker exec -it alwisp_web bash
# Open a MySQL shell
# Open a MySQL shell (use the DB container's br0 IP if connecting externally)
docker exec -it alwisp_db mysql -u alwisp_user -p alwisp
# Manual database backup
docker exec alwisp_db mysqldump -u alwisp_user -p alwisp > backup_$(date +%F).sql
docker exec alwisp_db mysqldump -u alwisp_user -p alwisp > /mnt/user/appdata/alwisp/backups/backup_$(date +%F).sql
```
---