Skip to content

Commit 1af09f1

Browse files
authored
Merge pull request #368 from mkulina/fix/arm-mariadb-volume-detection
fix: auto-detect ARM architecture for MariaDB volume configuration
2 parents 7770207 + 956bebc commit 1af09f1

File tree

6 files changed

+108
-22
lines changed

6 files changed

+108
-22
lines changed

docker-compose.arm.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Override file for ARM-based systems (Apple Silicon, Raspberry Pi, etc.)
2+
# This uses a named volume for MariaDB to work around virtiofs bugs on ARM
3+
4+
services:
5+
youtarr-db:
6+
volumes:
7+
- youtarr-db-data:/var/lib/mysql
8+
9+
volumes:
10+
youtarr-db-data:
11+

docker-compose.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
# mkdir -p config jobs server/images /path/to/youtube_videos
1616
# sudo chown -R 1000:1000 config jobs server/images /path/to/youtube_videos
1717
#
18-
# 2) Database setup notes for Synology and Apple Silicon macOS users:
19-
# There are known issues with using bind mounts for MariaDB data directories due to permission and virtiofs bugs respectively.
20-
# It is highly recommended to use a named volume for the youtarr-db service instead of the bind mount.
18+
# 2) Database setup notes for Synology and ARM-based systems (Apple Silicon, Raspberry Pi):
19+
# There are known issues with using bind mounts for MariaDB data directories due to permission and virtiofs bugs.
20+
# The start scripts automatically detect ARM architecture and use docker-compose.arm.yml override to switch to named volumes.
21+
# For Synology or manual override, run: docker compose -f docker-compose.yml -f docker-compose.arm.yml up -d
2122

2223
services:
2324
youtarr-db:
@@ -38,9 +39,6 @@ services:
3839
- "${DB_PORT:-3321}:${DB_PORT:-3321}"
3940
volumes:
4041
- ./database:/var/lib/mysql
41-
# Synology and Apple Silicon macOS users:
42-
# Uncomment the line below and comment out the line above to use named volume:
43-
# - youtarr-db-data:/var/lib/mysql
4442
command: --port=${DB_PORT:-3321} --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --innodb-file-per-table=1 --innodb-large-prefix=ON
4543
healthcheck:
4644
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-P", "${DB_PORT:-3321}", "-u", "${DB_USER:-root}", "-p${DB_PASSWORD:-123qweasd}"]
@@ -98,7 +96,6 @@ networks:
9896
default:
9997
name: youtarr-network
10098

101-
# Synology and Apple Silicon macOS users:
102-
# Uncomment the line below and comment out the line above to use named volume:
103-
# volumes:
104-
# youtarr-db-data:
99+
# Named volume definition (used by docker-compose.arm.yml override for ARM systems)
100+
volumes:
101+
youtarr-db-data:

docs/DOCKER.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ Youtarr uses Docker Compose with two containers:
2222
- **Image**: `mariadb:10.3`
2323
- **Port**: 3321 (both host and container)
2424
- **Volumes**:
25-
- `./database:/var/lib/mysql` - Database persistence
25+
- `./database:/var/lib/mysql` - Database persistence (default)
26+
- `youtarr-db-data:/var/lib/mysql` - Named volume (required for ARM/Synology)
2627
- **Character Set**: utf8mb4 (full Unicode support)
2728

29+
> **ARM Users**: See [ARM Architecture Notes](#arm-architecture-apple-silicon-raspberry-pi) below.
30+
2831
## ⚠️ Important: Do Not Mount the Migrations Directory
2932

3033
Avoid adding a `./migrations:/app/migrations` volume. The production image already includes the migration files it needs.
@@ -48,6 +51,45 @@ volumes:
4851
4952
If your automation creates a migrations directory, remove it from both directory creation and volume mounts.
5053
54+
## ARM Architecture (Apple Silicon, Raspberry Pi)
55+
56+
ARM-based systems (Apple Silicon Macs, Raspberry Pi, etc.) have known issues with MariaDB bind mounts due to virtiofs bugs. The start scripts automatically detect ARM and apply the fix.
57+
58+
### Using Start Scripts (Recommended)
59+
60+
The `./start.sh` script automatically detects ARM architecture and applies the correct configuration:
61+
```bash
62+
./start.sh
63+
```
64+
65+
### Using Docker Compose Directly
66+
67+
If you prefer running `docker compose` commands directly on ARM systems, use the override file:
68+
```bash
69+
docker compose -f docker-compose.yml -f docker-compose.arm.yml up -d
70+
```
71+
72+
This uses a named Docker volume instead of a bind mount for MariaDB data, avoiding the virtiofs issues.
73+
74+
### Manual Configuration
75+
76+
Alternatively, edit `docker-compose.yml` directly:
77+
```yaml
78+
services:
79+
youtarr-db:
80+
volumes:
81+
# Comment out bind mount:
82+
# - ./database:/var/lib/mysql
83+
# Use named volume:
84+
- youtarr-db-data:/var/lib/mysql
85+
86+
# Add at the bottom:
87+
volumes:
88+
youtarr-db-data:
89+
```
90+
91+
See [Troubleshooting](TROUBLESHOOTING.md#apple-silicon--arm-incorrect-information-in-file-errors) for more details on the underlying issue.
92+
5193
## Configuration Setup
5294
- **Create a .env file** to configure environment variables:
5395
```bash

docs/INSTALLATION.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ If you prefer to use standard `docker compose up` commands:
8181
docker compose up -d
8282
```
8383

84+
> **ARM Users (Apple Silicon, Raspberry Pi)**: Use the ARM override to avoid MariaDB volume issues:
85+
> ```bash
86+
> docker compose -f docker-compose.yml -f docker-compose.arm.yml up -d
87+
> ```
88+
> See [Troubleshooting](TROUBLESHOOTING.md#apple-silicon--arm-incorrect-information-in-file-errors) for details.
89+
8490
5. **Access the web interface**:
8591
- Navigate to `http://localhost:3087`
8692
- If you set preset credentials in .env, use those to log in

docs/TROUBLESHOOTING.md

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -347,31 +347,48 @@ ERROR 1396 (HY000) at line 21: Operation CREATE USER failed for 'root'@'%'
347347

348348
Tip: run with a named volume (see Apple Silicon/Synology sections) so filesystem corruption is less likely to recur.
349349

350-
### Apple Silicon: `Incorrect information in file` errors
350+
### Apple Silicon / ARM: `Incorrect information in file` errors
351351

352-
**Problem**: On Apple Silicon (M1/M2/M3/M4) running Docker Desktop, MariaDB logs errors like:
352+
**Problem**: On Apple Silicon (M1/M2/M3/M4) or other ARM systems running Docker Desktop, MariaDB logs errors like:
353353
```
354354
ERROR 1033 (HY000): Incorrect information in file: './youtarr/videos.frm'
355355
```
356356
This happens whenever MariaDB touches tables stored on a bind-mounted host directory (our default `./database:/var/lib/mysql`). Docker Desktop shares bind mounts over `virtiofs`, and MariaDB 10.3 cannot reliably reopen InnoDB tables on that filesystem ([MariaDB issue #447](https://github.com/MariaDB/mariadb-docker/issues/447), [#481](https://github.com/MariaDB/mariadb-docker/issues/481)). Linux and WSL users are unaffected.
357357

358-
**Solution** (switch to a named Docker volume):
358+
**Solution A: Use the start scripts (Recommended)**
359+
360+
The `./start.sh` and `./start-dev.sh` scripts automatically detect ARM architecture and apply the fix:
361+
```bash
362+
./start.sh
363+
```
364+
No manual configuration needed—the scripts use `docker-compose.arm.yml` as an override on ARM systems.
365+
366+
**Solution B: Manual docker compose (if not using start scripts)**
367+
368+
If you run `docker compose up` directly, use the ARM override file:
369+
```bash
370+
docker compose -f docker-compose.yml -f docker-compose.arm.yml up -d
371+
```
372+
373+
Or manually edit `docker-compose.yml` to use a named volume:
374+
359375
**NOTE:** Existing data will *not* be migrated!
360-
1. Stop the stack and remove the old volume `docker compose down -v`.
376+
1. Stop the stack: `docker compose down`
361377
2. Edit `docker-compose.yml`:
362378
```yaml
363379
services:
364380
youtarr-db:
365-
# Comment out the default bind mount line:
366-
# - ./database:/var/lib/mysql
367-
# And enable the named volume instead (charset tuning is built into the container command):
368-
- youtarr-db-data:/var/lib/mysql
381+
volumes:
382+
# Comment out the bind mount:
383+
# - ./database:/var/lib/mysql
384+
# Use named volume instead:
385+
- youtarr-db-data:/var/lib/mysql
369386

370-
# Ensure that the volume is defined
387+
# Add at the bottom of the file:
371388
volumes:
372389
youtarr-db-data:
373390
```
374-
4. Start Youtarr again (`./start.sh` or `docker compose up -d`). MariaDB will initialize inside `youtarr-db-data`, avoiding virtiofs entirely.
391+
3. Start Youtarr: `docker compose up -d`
375392

376393
**Alternatives**:
377394
- Point Youtarr at an external MariaDB/MySQL instance via `./start-with-external-db.sh`.

scripts/_start_template.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,24 @@ fi
3030
# shellcheck source=scripts/_shared_start_tasks.sh
3131
source "$SCRIPT_DIR/_shared_start_tasks.sh" "$@"
3232

33+
# Detect ARM architecture (Apple Silicon, Raspberry Pi, etc.)
34+
ARCH=$(uname -m)
35+
IS_ARM=false
36+
if [[ "$ARCH" == "arm64" || "$ARCH" == "aarch64" ]]; then
37+
IS_ARM=true
38+
yt_info "Detected ARM architecture ($ARCH) - using named volume for MariaDB"
39+
fi
40+
3341
if [ "$USE_EXTERNAL_DB" == "true" ]; then
3442
# Only start the youtarr service.
3543
COMPOSE_ARGS="-f docker-compose.external-db.yml up -d"
3644
else
37-
COMPOSE_ARGS="-f docker-compose.yml up -d"
45+
if [ "$IS_ARM" == "true" ]; then
46+
# Use ARM override to switch to named volume (works around virtiofs bugs)
47+
COMPOSE_ARGS="-f docker-compose.yml -f docker-compose.arm.yml up -d"
48+
else
49+
COMPOSE_ARGS="-f docker-compose.yml up -d"
50+
fi
3851
fi
3952

4053
$COMPOSE_CMD $COMPOSE_ARGS

0 commit comments

Comments
 (0)