(toiminnot)

hwechtla-tl: Running graphical programs from Docker containers

Kierre.png

Mikä on WikiWiki?
nettipäiväkirja
koko wiki (etsi)
viime muutokset


(nettipäiväkirja 14.10.2016) SoapUI is one of those softwares I don't want to install on my computer directly. (The tar installation is not as bad as the install script, but I don't like non-packaged software in general.) So one of the options is to run it from a Docker container instead.

However, it's a graphical program, so I need some way for it to contact my X server. SSH tunnelling is an option, but most Docker Hub images don't come with a running SSH daemon so I can't contact them by SSH. This is in accordance to the Docker philosophy where at optimum there is a single program running in every container.

An easier option is to mount the X11 Unix domain sockets to the container, because that's what X11 uses for local connections nowadays anyway. This is a lightweight version of the ideas in http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/

So we run the docker container like this:

docker run -it --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix \
  ruimo/df-ub1404-soapui521

Inside the docker container, we need some setup, because it's not designed to be used like this. In the bash that we get, we create a user to connect to the X11 socket with the right uid (= our uid on the host) and start SoapUI as that user. In the following command, write your UID on the host instead of 1000 in the command; if you don't know what it is, run the command "id" on your host:

root@1a60bee63647:/# useradd -u 1000 -g 0 someuser
root@1a60bee63647:/# sudo -u someuser /opt/SoapUI-5.2.1/bin/soapui.sh &

Ta-da! We get a SoapUI window on the X11 server we are using.

Another thing. You might need to contact your host machine from the SoapUI container -- for example if your SOAP service is running on the localhost. This is possible, if the processes you run on your host bind to all interfaces (0.0.0.0) and not just localhost (127.0.0.1). To find out the IP address you can use for contacting the host from the container, run this in the container:

root@1a60bee63647:/# /sbin/route -n | awk '$1 ~ "0.0.0.0" { print $2; }'
172.17.0.1

So, to contact my host process that listens to say port 8888, I'll have to contact http://172.17.0.1:8888/.


kommentoi (viimeksi muutettu 14.10.2016 12:59)