edit · print · PDF

Please note that all the SIEpedia's articles address specific issues or questions raised by IAC users, so they do not attempt to be rigorous or exhaustive, and may or may not be useful or applicable in different or more general contexts.

Using the latest MacPorts Python2 packages, the Molecfit GUI interface is broken, with missing and/or displaced elements. After trying to reinstall packages, or creating a specific virtual environment, we have been unable to solve the problem (which seems related to the version of the wxpython package).

We thus have decided to replicate the Molecfit installation under Ubuntu 18.04 (where it works fine) ina Docker container, and thus install and run such container on the Mac.

Install Docker on Mac

We must first install Docker on the Mac. Just follow the instructions on https://docs.docker.com/docker-for-mac/install/. Probably you need to register on the Docker website to be able to download and run the installer.

Create docker image for Molecfit

  • First step: download the image for Ubuntu 18.04:
    sudo docker pull ubuntu:bionic
  • Run the unminimize command inside the container so as to install the tools for human interaction.
    docker run -it --name ubuntu1804 ubuntu:bionic
    unminimize     (this inside the container)
  • Install necessary Python 2 packages, as well as gcc, make, and the xterm terminal
    apt install python-matplotlib python-wxtools python-wxversion python-astropy
    apt install gcc make xterm

Install Molecfit

Save and export the container

  • Commit the container (which create a new image)
    docker commit ubuntu1804
  • List availabe images
    docker images
  • Tag image with a meaningful name
    docker tag <hash> ubuntu1804_molecfit
    where the hash is the one displayed by the previous step.
    The image will be about 2 GB in size
  • Export the container
    docker container ls -a     # list available containers
    docker export <hash> > ~/molecfit_docker_container.tar
    where <hash> is the value for the container, listed in the previous command.

It should also possible to export the image, but when I tried it I received the error message: " Error response from daemon: file integrity checksum failed for "usr/share/locale/hu/LC_MESSAGES/iso_3166-1.mo" (even increasing the maximum value for the RAM allocated to Docker, and trying other tricks, I was unable to fix the error).

Import the container and run it

  • Import container: after the "molecfit_docker_container.tar" tarfile is copied to the Mac where Molecfit will be used, import it with:
    cat molecfit_docker_container.tar | sudo docker import - molecfit_docker
  • If not already done, go to Preferences under the XQuartz menu, click on the security tab and ensure "Allow connections from network clients" is checked (here we partly follow the steps listed in https://sourabhbajaj.com/blog/2017/02/07/gui-applications-docker-mac/)
  • Open an XQuartz terminal and run:
    @@xhost + 127.0.0.1
  • Finally, in the same terminal, run the docker command in the following way:
    docker run -it --name m1 -e DISPLAY=host.docker.internal:0 -v /tmp/.X11-unix:/tmp/.X11-unix -v /Users/username/:/home/username/ molecfit_docker xterm
    # -v means: mount directory of host system on directory of container: the first element is the directory in the host machine, the second in the container (does not need to exist). "m1" is the name we assign to the new container instance, while "molecfit_docker" is the name of the image created in the import step above.
    Note: The host.docker.internal:0 is a setting specific for Docker Desktop for Mac. See https://docs.docker.com/docker-for-mac/networking/ for details.

At this point, an xterm should open, and we are inside the container. Running /opt/molecfit/bin/molecfit_gui should open the Molecfit GUI interface. Remember that /home/username/ in the container is the same as /Users/username/ in the host (Mac) system, so be careful if you wish to delete anything.

All files created in /home/username/ will also be in /Users/username/, so they will remain there after you close or even delete the container.

When finished, exit from the container and type xhost - 127.0.0.1

Some useful Docker commands

  • List all images
    docker images
  • List all containers
    docker container ls -a
  • Delete container
    docker container rm <CONTAINER_ID>     # where <CONTAINER_ID> is the alphanumerical hash
  • Delete image
    docker image rm <IMAGE_ID>
  • Restart a stopped container
    docker start <CONTAINER_NAME>
edit · print · PDF
Page last modified on December 03, 2019, at 10:58 AM