Digikam on Mac OS X or how to use Docker to run a graphical app on Mac OS X
Digikam is a very powerful and convenient KDE application to manage a photo collection (batch renaming, batch auto rotate, modification of geoexif, etc.).
Thing is, Digikam is mainly targeted at Linux distributions; and I’m currently not using a Linux based OS (bad, bad, bad…); so I could follow along the official instructions, such as :
- get it from mac ports : but I use brew, and mac ports really failed on me several times
- download it from KDE downloads, ->to be honest, the best solution if you don’t mind installing an untrusted pkg
Since there exists a pkg installer for Mac OS X, you could stop there. But for those Linux UI apps that don’t have a Mac OS X build, read on; as another option would be to use Docker to run Digikam.
Using Docker and the Guacamole based (clientless rdp and vnc) image : aptalca/docker-digikam
This image can be found on Dockerhub, and can be started with the following command line :
$ docker run -d --name="digikam-guacamole" -e EDGE="0" -e HEIGHT="720" -e WIDTH="1280" -v ${HOME}/Pictures/:/nobody/Pictures -p 9999:8080 aptalca/docker-digikam
provided the folder where you store your pictures is located at ~/Pictures
Make sure it is started :
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ebfe0d8fb576 aptalca/docker-digikam "/sbin/my_init" 9 seconds ago Up 8 seconds 3389/tcp, 0.0.0.0:9999->8080/tcp digikam-guacamole
Then point your web browser to: http://192.168.99.100:9999/#/client/c/digiKam (replace the ip address with your local Docker daemon VM)
It’s very easy to get started, thanks to the embedded html5 XRDP / VNC client in your browser, but unfortunately, the window can’t be resized dynamically, and since Digikam is run as a non root user (nobody), I had to chmod my ~/Pictures folder to 777, and even with that it never loaded my pictures (probably because of read/write access); so I gave this solution up and tried something more interesting…
Using Docker and X11
This solution is a bit more complicated, but leads to better results, because it is going to connect your Digikam Docker container to your Mac X11 server.
Most of the steps to get it working are coming from this github thread where Slobodan Mišković describes how to wire your X11 sock to a socket, so that your X11 display can be accessible from a container – also, have a look at this article from Jessie Frazelle about running graphical app with Docker
Now, to make this solution work, you need some prerequisites :
- install brew a very good package manager for Mac OS X,
- install caskroom , the brew extension for UI apps:
brew install caskroom/cask/brew-cask
- when X11 is installed, make sure it exported its DISPLAY environment variable, it should look like :
$ echo $DISPLAY /private/tmp/com.apple.launchd.BvS3QOiihF/org.macosforge.xquartz:0
if not, try rebooting (!) your mac, or at least re open your session.
Then run : (it won’t return)
$ socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"
Now you can connect applications to your X11 display server using port 6000; the IP address should be the one assigned to your Virtual Box VM running Docker; use ifconfig locally on your mac to find out your Virtual Box interface IP address :
$ ifconfig vboxnet(0|1|2): flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 ether 0a:00:27:00:00:02 inet 192.168.99.1 netmask 0xffffff00 broadcast 192.168.99.255
in my case : 192.168.99.1
Now you can check this IP address is accessible from a container :
$ docker run -i ubuntu ping 192.168.99.1 PING 192.168.99.1 (192.168.99.1) 56(84) bytes of data. 64 bytes from 192.168.99.1: icmp_seq=1 ttl=63 time=0.212 ms
and try starting a graphical linux app, such as one from Jessie Frazelle :
docker run -e DISPLAY=192.168.59.3:0 jess/geary
Now on to digikam ! Let’s try using this Digikam Docker Image from Silvano Cirujano Cuesta ; since we are running it on a Mac using X11 on a socket, we need to adapt a little bit the instructions :
$ docker run --user user-dk --name digikam -it -v ${HOME}/Pictures:/home/user-dk/Pictures -e DISPLAY=192.168.99.1:0 silvavlis/digikam
:0 means we’ll use the first server, from 6000 X11 default port.
Not bad , huh ? Don’t forget to enable right-click and middle click from X11 preferences :
Reference: | Digikam on Mac OS X or how to use Docker to run a graphical app on Mac OS X from our SCG partner Anthony Dahanne at the Anthony Dahanne’s blog blog. |