Browser Gui In Docker For Mac

Автор:

This article introduce how to run GUI apps and Firefox with Docker for Mac, the purpose is just for fun, maybe can be used for build Website test automation with docker, you can check this.

All the commands below are tested with Docker 17.03.0-ce, macOS 10.12.3 and XUbuntu 16.04.2.

It include three sections here:

Kitematic is the default GUI that ships with Docker for Mac and Windows. I won’t cover it in much detail as you likely know it well already. When Kitematic first emerged, it was one of the few GUI options available, and when Docker acquired the project in October 2015, I had high hopes for its development. Docker for Firefox GUI running on Linux and macOS. Contribute to playniuniu/docker-gui-firefox development by creating an account on GitHub.

  1. How to run GUI for Linux

  2. How to run GUI for macOS

  3. How to write Firefox Dockerfile

If you don't have so many times, you can just read Finally commands on each end of section :)

How to run GUI for Linux

Let's start with a normal GUI app xeyes, here is the Dockerfile based on Alpine Linux:

You can built your own images with docker build -t xeyes ..

To run Docker GUI on Linux, You need 3 steps here:

  1. Add docker's X11 authority

  2. Set $DISPLAY environment for Docker

  3. Loading X11 sockets for Docker

Finally commands
  1. Build Dockerfile

  2. Add X11 authority

  3. Run docker GUI apps

Now you can see an X11 xeyes apps in your screen.

How to run GUI for macOS

The macOS is a little more complicate for it's lack of X-Window system,

so you need extra two steps to run GUI apps on macOS when you finished build xeyes images.

  1. Establish the X11 server

  2. Forward linux X11 socket to macOS X11 server ( Important! )

Notes: Lots of articles online lack of the second step, so cannot successfully run GUI on macOS.

For the two steps above, you need install two softwares here:

  1. XQuartz, you can install it with brew cask install xquartz

  2. socat, you can install it with brew install socat

Finally commands

So finally, you need five steps for run GUI apps on macOS:

  1. Forward X11 socket

  2. Check your macOS's ip

  3. Add X11 authority ( optional )

  4. Open XQuartz software

  5. Run Docker GUI apps

Now, you can see xeyes on your macOS.

How to write Firefox Dockerfile

For Firefox, all the command steps are same, but you can not just simply replace the package xeyes with Firefox. The Firefox's Dockerfile need some extra steps below to reach the goal:

  1. Install dbus-x11 package

  2. Install a fonts for Firefox

  3. Change to normal user to run Firefox

  4. Prepare a profile folder for Firefox or use firefox --new-instance

The Dockerfile example is here:

You can also check my GitHub from more detail.

Finally commands

For Linux Platform, you can run Firefox with docker with:

  1. Add X11 authority

  2. Run Firefox in Docker

For macOS platform, same five steps as above:

  1. Forward X11 socket

  2. Check your macOS's ip

  3. Add X11 authority ( optional )

  4. Open XQuartz software

  5. Run Docker GUI apps

Reference

In a PS to Using Docker as a Personal Productivity Tool – Running Command Line Apps Bundled in Docker Containers, I linked to a demonstration by Jessie Frazelle on how to connect to GUI based apps running in a container via X11. This is all very well if you have an X client, but it would be neater if we could find a way of treating the docker container as a virtual desktop container, and then accessing the app running inside it via the desktop presented through a browser.

Digging around, Guacamole looks like it provides a handy package for exposing a Linux desktop via a browser based user interface [video demo].

Very nice… Which got me wondering: can we run guacamole inside a container, alongside an X.11 producing app, to expose that app?

Via the Dockerfile referenced in Digikam on Mac OS/X or how to use docker to run a graphical app on Mac OS/X I tracked down linuxserver/dockergui, a Docker image that “makes it possible to use any X application on a headless server through a modern web browser such as chrome”.

Exciting:-) [UPDATE: note that that image uses an old version of the guacamole packages; I tried updating to the latest versions of the packages but it doesn’t just work so I rolled back. Support for Docker was introduced after the version used in the linuxserver/dockergui, but I don’t fully understand what that support does! Ideally, it’d be nice to run a guacamole container and then use docker-compose to link in the applications you want to expose to it? Is that possible? Anyone got an example of how to do it?]

So I gave it a go with Audacity. The files I used are contained in this gist that should also be embedded at the bottom of this post.

(Because the original linuxserver/dockergui was quite old, I downloaded their source files and built a current one of my own to seed my Audacity container.)

Building the Audacity container with:

docker build -t psychemedia/audacitygui .

and then running it with:

docker run -d -p 8080:8080 -p 3389:3389 -e 'TZ=Europe/London' --name AudacityGui psychemedia/audacitygui

this is what pops up in the browser:

If we click through on the app, we’re presented with a launcher:

Select the app, and Hey, Presto!, Audacity appears…

It seems to work, too… Create a chirp, and then analyse it:

We seem to be able to load and save files in the nobody directory:

I tried exposing the /nobody folder by adding VOLUME /nobody to the Dockerfile and running a -v '${PWD}/files':/nobody switch, but it seemed to break things which is presumably a permissions thing? There are various user roles settings in the linuxserver/dockergui build files, so making poking around with those would fix things? Otherwise, we might have to see the container directly with any files we want in it?:-(

All postings and use of the content on this site are subject to the. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. Dialux for mac. Apple Footer.This site contains user submitted content, comments and opinions and is for informational purposes only. Apple may provide or recommend responses as a possible solution based on the information provided; every potential issue may involve several factors not detailed in the conversations captured in an electronic forum and Apple can therefore provide no guarantee as to the efficacy of any proposed solutions on the community forums.

UPDATE: adding RUN mkdir -p /audacityfiles && adduser nobody root to the Dockerfile along with ./VOLUME /audacityfiles and then adding -v '${PWD}/files':/audacityfiles when I create the container allows me to share files in to the container, but I can’t seem to save to the folder? Nor do variations on the theme, such as s creating a subfolder in the nobody folder and giving the same ownership and permissions as the nobody folder. I can save into the nobody folder though. (Just not share it?)

WORKAROUND: in Kitematic, the Exec button on the container view toolbar takes you into the container shell. From there, you can copy files into the shared direcory. For example: cp /nobody/test.aup /nobody/share/test.aup Moving the share to a folder outside /nobody, eg to /audacityfiles means we can simply compy everything from /nobody to /audacityfiles.

Another niggle is with the sound – one of the reasons I tried the Audacity app… (If we can have the visual of the desktop, we want to try to push for sound too, right?!)

Unfortunately, when I tried to play the audio file I’d created, it wasn’t having any of it:

Looking at the log file of the container launch in Kitematic, it seems that ALSA (the Advanced Linux Sound Architecture project) wasn’t happy?

I suspect trying to fix this is a bit beyond my ken, as too are the sorting out the shared folder permissions, I suspect… (I don’t really do sysadmin – which is why I like the idea of ready-to-run application containers).

UPDATE 2: using a different build of the image – hurricane/dockergui:x11rdp1.3, from the linuxserver/dockergui x11rdp1.3 branch, audio does work, though at times it seemed to struggle a bit. I still can’t save files to shared folder though:-(

UPDATE 3: I pushed an image as psychemedia/audacity2. It works from the command line as:
docker run -d -p 8080:8080 -p 3389:3389 -e 'TZ=Europe/London' --name AudacityGui -v '${PWD}':/nobody/share psychemedia/audacity2

Anyway – half-way there. If nothing else, we could create and analyse audio files visually in the browser using Audacity, even if we can’t get hold of those audio files or play them!

I’d hope there was a simple permissions fix to get the file sharing to work (anyone? anyone?! ;-) but I suspect the audio bit might be a little bit harder? But if you know of a fix, please let me know:-)

Therefore, you have to upgrade to 10.13 to use CUDA 10.You can install python 3.7 by brew install pythonor download the latest Anaconda.祝祖国生日快乐:). (All possible capabilities on Mac OS. (All possible capabilities on Mac OS. If you find anything missing, please open an issue.)CUDA 10.0 and CuDNN 7.4 are required.Note CUDA 10 driver cannot work normally on Mac OS 10.12. Download tensorflow mac 2. This release version is built for Tensorflow 1.14.0rc1 for Python 2.7, 3.7 on Mac OS X 10.13 with GPU (CUDA) support.Supported CUDA compute capability: 3.0,3.5,5.0,5.2,6.1,7.0.

PS I just tried launching psychemedia/audacity2 public Dockerhub image via Docker Cloud, and it seemed to work…