Audiobookshelf in Docker Swarm
Get your FREE "elfhosted" Audiobookshelf instance for demo / trial
Want to see a live demo, or "kick the tyres" before you commit to self-hosting Audiobookshelf?
- Fully open-source, including the android & iOS app (in beta)
- Stream all audio formats on the fly
- Search and add podcasts to download episodes w/ auto-download
- Multi-user support w/ custom permissions
- Keeps progress per user and syncs across devices
- Auto-detects library updates, no need to re-scan
- Upload books and podcasts w/ bulk upload drag and drop folders
- Backup your metadata + automated daily backups
- Progressive Web App (PWA)
- Chromecast support on the web app and android app
- Fetch metadata and cover art from several sources
- Basic ebook support and e-reader (experimental)
- Merge your audio files into a single m4b w/ metadata and embedded cover (experimental)
- DNS entry for your auth host ("audiobookshelf.yourdomain.com" is a good choice), pointed to your keepalived IP
Setup data locations
First, we create a directory to hold the metadata and config (Audiobookshelf docs indicate that these should be separate directories):
mkdir /var/data/audiobookshelf/metadata mkdir /var/data/audiobookshelf/config
It's helpful to keep environment variables in a separate file, so create
/var/data/config/audiobookshelf/audiobookshelf.env, as follows (you may want to customise the UID/GID to match those of your media folder):
Audiobookshelf Docker Swarm config
Create a docker swarm config file in docker-compose syntax (v3), something like the example below.. example:
Fast-track with premix! 🚀
I automatically and instantly share (with my sponsors) a private "premix" git repository, which includes necessary docker-compose and env files for all published recipes. This means that sponsors can launch any recipe with just a
git pull and a
docker stack deploy 👍.
🚀 Update: Premix now includes an ansible playbook, so that sponsors can deploy an entire stack + recipes, with a single ansible command! (more here)
version: '3' services: app: image: advplyr/audiobookshelf env_file: /var/data/config/audiobookshelf/audiobookshelf.env volumes: - /var/data/audiobookshelf/config:/config - /var/data/audiobookshelf/metadata:/metadata # Set this next volume to wherever you store your audiobook library. # You can define multiple libraries within this folder, like `/media/audio/podcasts`, `/media/audio/audiobooks`, etc - /var/data/media:/media deploy: replicas: 1 labels: # traefik - traefik.enable=true - traefik.docker.network=traefik_public # traefikv1 - traefik.frontend.rule=Host:audiobookshelf.example.com - traefik.port=80 # traefikv2 - "traefik.http.routers.audiobookshelf.rule=Host(`audiobookshelf.example.com`)" - "traefik.http.routers.audiobookshelf.entrypoints=https" - "traefik.http.services.audiobookshelf.loadbalancer.server.port=80" networks: - traefik_public networks: traefik_public: external: true
Should we use Traefik Forward Auth?
No, because (a) the mobile apps won't work with session/cookie based auth, and (b) the docs indicate that using middleware which alters CORS with Traefik will cause the app to error!
Launch the audiobookshelf stack by running
docker stack deploy audiobookshelf -c <path -to-docker-compose.yml>
Now hit the URL you created for Audiobookshelf, and you'll find yourself presented with the "Initial Server Setup". After creating a user and password, setup your libraries, and then either stream your audio directly in your browser, or fire up the Android / iOS app and listen on the go! 1
What have we achieved? We can now easily consume our audio books / podcasts via Audiobookshelf, securely over our Traefik-exposed service! 2
- Audiobookshelf is running, able to access your media libraries, and is streaming books / podcasts to you, wherever you are!
Chef's notes 📓
Tip your waiter (sponsor) 👏
Did you receive excellent service? Want to compliment the chef? (..and support development of current and future recipes!) Sponsor me on Github / Ko-Fi / Patreon, or see the contribute page for more (free or paid) ways to say thank you! 👏
Employ your chef (engage) 🤝
Is this too much of a geeky PITA? Do you just want results, stat? I do this for a living - I'm a full-time Kubernetes contractor, providing consulting and engineering expertise to businesses needing short-term, short-notice support in the cloud-native space, including AWS/Azure/GKE, Kubernetes, CI/CD and automation.
Learn more about working with me here.
Flirt with waiter (subscribe) 💌
Want to know now when this recipe gets updated, or when future recipes are added? Subscribe to the RSS feed, or leave your email address below, and we'll keep you updated.