Skip to content

Instantly share code, notes, and snippets.

@demaniak
Last active October 22, 2024 08:50
Show Gist options
  • Save demaniak/9ba65a8d0412256fd7cf010dd1adf235 to your computer and use it in GitHub Desktop.
Save demaniak/9ba65a8d0412256fd7cf010dd1adf235 to your computer and use it in GitHub Desktop.
Jellyfin 10.8.13 running as docker swarm service WITH hardware acceleration
# Step 1: device nodes
Use [this project](https://github.com/allfro/device-mapping-manager) to brute force device nodes into running containers.
Do this by running it as a docker swarm service like so:
`docker-compose.yml`:
```
services:
device-mapping-manager:
image: alpinelinux/docker-cli
entrypoint: docker
command: |
run
--rm
-i
--name device-manager
--privileged
--cgroupns=host
--pid=host
--userns=host
-v /sys:/host/sys
-v /var/run/docker.sock:/var/run/docker.sock
ghcr.io/allfro/allfro/device-mapping-manager:sha-0651661
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
deploy:
mode: global
restart_policy:
condition: any
placement:
constraints:
- node.labels.dmm == true
```
The placement constraint is optional, I wanted to only have it on specific workder nodes, maybe you want it somewhere else.
# Step 2: Jellyfin as a swarm service
Note this is just a cut-down sample to illustrate a bare-bones working sample.
You will/might need to adjust some values, like:
- timezone
- JELLYFIN_PublishedServerUrl
- media bind mount volumes
- jellyfin data volumes
- port mappings
- resource contraints (yes, jellyfin CAN run with a limit of 768Mb, but YMMV, adjust as needed and your hardware allows).
The important part for HW accel is `- /dev/dri:/dev/dri/`, under the volumes section.
If using plain docker-compose, you can achieve the same with the `devices` key, BUT with swarm, that capability has never matured.
So we have this work-a-round.
```
services:
jellyfin:
image: jellyfin/jellyfin:10.8.13
healthcheck:
interval: 30s
timeout: 10s
retries: 60
start_period: 30m
ports:
- 7359:7359/udp
- 8096:8096
deploy:
placement:
constraints:
- node.labels.dmm == true
restart_policy:
condition: on-failure
delay: 60s
window: 120s
resources:
limits:
cpus: '3.0'
memory: 768M
environment:
- TZ=YourCountry/YourCity
- PUID=1000
- PGID=1000
- JELLYFIN_PublishedServerUrl=your.hostname.here
volumes:
- /media/mymedia:/mymedia:ro
- /myjellyfin/cache:/cache
- /myjellyfin/config:/config
- /dev/dri:/dev/dri/ #This is the important part for hw accel!
```
# Notes
You can possibly opt to combine the two services into a single stack, if you have NOTHING else that requires device access.
I have not tested this however, there might be a race condition situation (?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment