PyMOL is a great program that runs natively on all 3 major platforms. However, I wanted to use a docker image that allegedly can run PyMOL (albeit an older version 1.8.2.) The reason might not be apparent at first but while the 3D interactivity would be slow, there can be other reason such a contraption could be useful, one of them could be to use PyMOL as a python interpreter, or to use PyMOL without a graphical interface to manipulate coordinates within a script, for example changing a chain name from
X11 – the tricky part
Docker is inherently a Linux process at the base and therefore the graphical interface of PyMOL within a (Linux-based) docker would have to be X11. So an X11 software must be installed on the local machine XQuarz for Mac, and e.g. Xming on Windows
There are a few docker images for PyMOL on the Docker hub, some have not been updated in years. I have identified two that work, even though one was updated only 15 days ago it runs the same PyMOL version of 1.8.x as the one last updated 3 years ago.
In testing I had to issue some commands that may or may not be relevant to all, but seemed to make a difference for my Mac running the current XQuarz (2.7.11) and macOS 10.14.6 (Mojave.)
Here are the commands that made a difference to avoid X11 errors, both entered on a terminal.
defaults write org.macosforge.xquartz.X11 enable_iglx -bool true
The above command should be given while XQuarz is Not running.
The Xquartz set-up must accept network connections, which is not the default. Follow these steps:
XQuartzgo to menu:
Xquartz > Preferences...
- click on
- activate option “Allow connections from network clients”
The local computer must be instructed that X11 information should go through. This is done with program
xhost that will create an authorized list:
xhost + 127.0.0.1
An alternate command is:
xhost + localhost
This is the final most tricky command and defines how graphics coming from the container can reach the screen of the Mac…
Starting PyMOL from container
If all went well, it should be possible to start any of these 2 containers with command:
docker run --rm --user root -it -e DISPLAY=docker.for.mac.localhost:0 edwinksl/pymol
or the more recent image:
docker run --rm -it -e DISPLAY=docker.for.mac.localhost:0 pegi3s/pymol pymol
Or with the alternative
docker run --rm -it -e DISPLAY=host.docker.internal:0 pegi3s/pymol pymol
PyMOL without graphics
It is possible indeed to use PyMOL without its graphical interface as stated above, for example invoking PyMOL with command line
pymol -cq somescript.py
This may be the subject of a future workshop.