Skip to content

Instantly share code, notes, and snippets.

@matinrco
Last active August 23, 2024 14:24
Show Gist options
  • Save matinrco/6a11baed1c2f19b27656170783ddf380 to your computer and use it in GitHub Desktop.
Save matinrco/6a11baed1c2f19b27656170783ddf380 to your computer and use it in GitHub Desktop.

Run OpenModelica GUI with Docker on Mac OS host

  1. First you need docker , brew , XQuartz and socat on your host.

    • docker : Install docker desktop from here
    • brew : Follow installation instruction from here
    • XQuartz : Install by : brew cask install xquartz
    • socat : Install by : brew install socat
  2. Now run this in new terminal :

    socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"

    This command is going to use socat to make a unix socket (which is made by XQuartz to make X server) to tcp redirection/conversion . In this way you can access your xserver on your local network. 6000 is default xserver tcp port for listening. To findout more about used flags you can refer to here. Now leave current terminal open and go to next step.

  3. In new terminal window enter following commands & hit enter one by one :

    IP=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')

    With this commnad you are going to extract your host ip address from en0 network interface by ifconfig utility and assign it to new IP variable. if you type echo $IP you can see IP variable content.

    xhost + $IP

    xhost program is used to add your ip address to the list of allowed sources to make connections to the xquartz X server.

    docker run -it --rm --privileged --net=host -e DISPLAY=$IP:0 -v /tmp/.X11-unix:/tmp/.X11-unix openmodelica/openmodelica:v1.14.1-gui OMEdit

    This is last command which is going to run OpenModelica docker image . after you hit enter docker will pull openmodelica/openmodelica version 1.14.1 image from docker hub and run it interactivly by attaching your shell to the running container (-it) and pass your host ip address as a environment variable by naming it DISPLAY and using docker -e flag. It also mounts your local x server unix socket (/tmp/.X11-unix) to the container with -v flag. At the end it will run OMEdit from container file system. If you stop container by any means (e.g hiting ctrl+c) docker will delete your container (--rm).


Credits to : Foad from here

@Foadsf
Copy link

Foadsf commented Apr 15, 2020

For those who end up here, if you have more questions join the Discord channel for Modelica Language

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment