Spotify in Docker Container

In my previous article here, I’ve discussed how can we launch GUI Apps like Firefox Browser, Nautilus File Manager in Docker.
Today, I’m again with another GUI App in Docker container, Spotify.
For a GUI Application to run, we need to have an XServer which is available as part of every Linux Desktop Environment.
For Windows, you can use Xming.
For OSX, you can use Xquarkz.

But within a Container, we don’t have any XServer — so we will:
- Mount the
X11
socket residing in/tmp/.X11-unix
on your local machine into/tmp/.X11-unix
in the container.
-v /tmp/.X11-unix:/tmp/.X11-unix
- share the Host’s DISPLAY environment variable to the Container
-e DISPLAY=$DISPLAY
- run container with host network driver with
--net=host
- for sound
--device /dev/snd
Dockerfile to build an image with a Spotify App:
$ cat Dockerfile
$ sudo docker build -t mtabishk/spotify-app .
Docker Hub: https://hub.docker.com/repository/docker/mtabishk/spotify-app
$ sudo docker run --rm -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --net=host --device /dev/snd mtabishk/spotify-app

You should see the Spotify application now displayed on your Host OS Desktop.
Video Demo:
That’s all for today! I’ll be back with some new articles very soon, thanks! 🤗
Muhammad Tabish Khanday
LinkedIn: https://www.linkedin.com/in/mtabishk/