Image for post
Image for post
Spotify

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.

Image for post
Image for post
Wikipedia

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

Image for post
Image for post

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/

Lets code 💻.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store