Containerized Mopidy music server with support for MPD clients and HTTP clients.
Originally a fork of https://github.com/wernight/docker-mopidy, but has been highly modified since.
- Based on
Ubuntu
official (ubuntu:latest
) - Extremely easy to add new plugins through PR, most are just a single line addition to the
Dockerfile
. - Backend extensions:
- Standards: DLNA(dLeyna)
- Mopidy-Spotify for Spotify (Premium)
- Mopidy-GMusic for Google Play Music
- Mopidy-SoundClound for SoundCloud
- Mopidy-YouTube for YouTube
- AudioAddict (difm)
- More
- Frontend extensions:
- Standards: MPD, HTTP
- Mopidy-Scrobbler
- Mopidy-API-Explorer
- Mopidy-Local-Images
- Mopidy-Material-Webclient
- Mopidy-Mopify
- Mopidy-MusicBox-Webclient
- Mopidy-Spotmop
- Mopidy-Moped
- Mopidy-Webhooks
- Mopidy-Notifier
- More
- Runs as
app
user inside the container for security.
You may install additional backends or frontends.
First to make audio from from within a Docker container, you should enable PulseAudio over network; so if you have X11 you may for example do:
-
Install PulseAudio Preferences. Debian/Ubuntu users can do this:
$ sudo apt-get install paprefs
-
Launch
paprefs
(PulseAudio Preferences) > "Network Server" tab > Check "Enable network access to local sound devices" (you may check "Don't require authentication" to avoid mounting cookie file described below). -
Restart PulseAudio
$ sudo service pulseaudio restart
or
$ pulseaudio -k $ pulseaudio --start
On some distributions, it may be necessary to completely restart your computer. You can confirm that the settings have successfully been applied running
pax11publish | grep -Eo 'tcp:[^ ]*'
. You should see something liketcp:myhostname:4713
.
A script is provided to easily start a container using the latest image against your local pulseaudio daemon: run
.
It's also stored in the image for easy access.
Use it like so, all options are optional, although the more you provide the more functionality you'll have.
docker run --rm trevorj/mopidy-extras host run \
-o spotify/username='BLAH' -o spotify/password='BLAH' \
-o gmusic/username='BLAH' -o gmusic/password='BLAH' \
-o spotify_web/client_id='BLAH' -o spotify_web/client_secret='BLAH' \
-o scrobbler/username='BLAH' -o scrobbler/password='BLAH' \
-o audioaddict/username='BLAH' -o audioaddict/password='BLAH' \
-o soundcloud/auth_token='BLAH' \
| bash
You can also use docker-compose
using the provided docker-compose.yml
file. This works by forwarding your local
PulseAudio configuration into the container as a volume instead of passing in the cookie as an environment variable.
# in repo
docker-compose run --service-ports mopidy \
-o spotify/username='BLAH' -o spotify/password='BLAH' \
-o gmusic/username='BLAH' -o gmusic/password='BLAH' \
-o spotify_web/client_id='BLAH' -o spotify_web/client_secret='BLAH' \
-o scrobbler/username='BLAH' -o scrobbler/password='BLAH' \
-o audioaddict/username='BLAH' -o audioaddict/password='BLAH' \
-o soundcloud/auth_token='BLAH'
See mopidy's command for possible additional options.
Most elements are optional (see some examples below). Replace BLAH' accordingly if needed, or disable services (e.g.,
-o spotify/enabled=false`):
- For Spotify you'll need a Premium account.
- For Google Music use your Google account (if you have 2-Step Authentication, generate an app specific password).
- For SoundCloud, just get a token after registering.
- For AudioAddict, you need a premium account if you want to set the quality past 64k, otherwise account is optional.
Ports:
- 6600 - MPD server (if you use for example ncmpcpp client)
- 6680 - HTTP server (if you use your browser as client)
Environment variables:
PULSE_SERVER
- PulseAudio server socket.PULSE_COOKIE_DATA
- Hexadecimal encoded PulseAudio cookie commonly at~/.config/pulse/cookie
.
Volumes:
/app/Music
($XDG_MUSIC_DIR
) - Path to directory with local media files (optional)./app/.local/share/mopidy
($XDG_DATA_HOME/mopidy
) - Path to directory to store local metadata such as libraries and playlists in (optional).
-
Give read access to your audio files to user 1000 (
app
ala$APP_USER
), group 1000 (app
) or 29 (audio
), or even all users (e.g.,$ chgrp -R 29 $PWD/media && chmod -R g+r $PWD/media
).- Work is currently being done to provide a more dynamic permission allocation.
-
Index local files:
$ docker run --rm trevorj/mopidy-extras host run mopidy local scan | bash
-
Start the server:
docker run --rm trevorj/mopidy-extras host run \
-o spotify/username='BLAH' -o spotify/password='BLAH' \
-o gmusic/username='BLAH' -o gmusic/password='BLAH' \
-o spotify_web/client_id='BLAH' -o spotify_web/client_secret='BLAH' \
-o scrobbler/username='BLAH' -o scrobbler/password='BLAH' \
-o audioaddict/username='BLAH' -o audioaddict/password='BLAH' \
-o soundcloud/auth_token='BLAH' \
| bash
-
Browse to http://$HOST:6680/
$ xdg-open http://$HOST:6680
Example using ncmpcpp MPD console client
Start the server using the commands above, then run ncmpcpp any usual way, ala:
$ docker run --rm -it wernight/ncmpcpp ncmpcpp --host "$HOST"
Having more issues? Report a bug on GitHub. Also if you need some additional extensions/plugins that aren't already installed (please explain why).