Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

OpenModelica Docker Image available

OpenModelica Docker Image available

I've created an OpenModelica Docker image that includes a desktop.  There are two versions, one is stable (1.16) and the other is based on the newest nightly (1.17.x).  To use them first Install docker (on Mac, Windows or Linux) then run either:
docker run -d -p 25901:5901 -p 26901:6901 dersh/om-desktop-stable

or

docker run -d -p 25901:5901 -p 26901:6901 dersh/om-desktop-nightly

Then connect to the instance by using a web browser to go to:

http://localhost:26901/vnc.html?password=headless

and you should see a desktop and be able to run OpenModelica. 
You should also be able to run the docker image on a remote machine and then connect to it for viewing, as above.

Re: OpenModelica Docker Image available

Really cool! I did a similar thing some time ago without the webhost using an XServer. So you can actually use copy&paste in OMEdit, resize the Window and so on and there is no difference to a normal app started.

Your image is working fine on Windows with WSL2, but apparently ModelicaReference is missing.

Also you can probably reduce the size of your image by removing var/lib/apt/lists and do a apt-get clean.
This Code is for Ubuntu, but is probably working for Xubuntu as well.

Code:


RUN rm -rf /var/lib/apt/lists/* \
  && apt-get clean

Re: OpenModelica Docker Image available

Just add

Code:

apt-get install -qy openmodelica omlib-modelica-3.2.3 omlib-modelicareference

to your Dockerfile.

For comparison you can find my image on DockerHub: /hub.docker.com/repository/docker/anheuermann/openmodelica/general

Re: OpenModelica Docker Image available

Thanks for the suggestions.  I think that the rm has to be in the same RUN command, or it will cause a new layer to be added, so there is no net benefit in the size.
I've implemented both suggestions (I added the rm to the layer).  They are building now and should be available shortly.
X11 from/to Docker can be annoying to setup properly.  So, hopefully this implementation can make it easier for any users.

Re: OpenModelica Docker Image available

This is quite cool. You could have made them in the same repository sand different tags though. At least this avoids the need of an X server or virtual machine.

Although I didn't test the images myself, it seems like it would listen to external connections. It would be safer to not expose the port and instead just connect to the container directly. But MacOS and Windows have some limitations in that regard...
Keep in mind that docker is a pretty big security risk.

Re: OpenModelica Docker Image available

I would suggest using

Code:

docker run -d -p 127.0.0.1:25901:5901 -p 127.0.0.1:26901:6901 dersh/om-desktop-nightly

To not let outside machines connect to the exposed VNC port.

Re: OpenModelica Docker Image available

I need help:
I have a docker image and install ubuntu inside it and want to install open Modelica in ubuntu on this image and then create a new image from that, something like your work.

could you explain how could I do that?

Re: OpenModelica Docker Image available

See for example the Dockerfile we generate for OpenModelica + Jupyter Notebook: https://github.com/OpenModelica/jupyter … Dockerfile

But basically you do exactly the same as when installing OpenModelica inside your Linux. To get a feeling just start to run a docker container like ubuntu:focal with a shell and follow the Linux install instructions for OpenModelica (https://openmodelica.org/download/download-linux).

Code:


$docker run --rm -it ubuntu:focal bash

If you want GUI support inside your docker container you have to hack a bit more (hint: ENV DISPLAY=host.docker.internal:0.0 and a configured XServer on your host system).

Re: OpenModelica Docker Image available

You can just look at the dockerfiles that I created.  All they do is take a base image for xubuntu and add OpenModelica on top.  I chose an image that includes a GUI that is accessible from the host using novnc, so that you don't have to use X11 on your host. 
In case you are having trouble finding the files they are here and here

Re: OpenModelica Docker Image available

ok I install this image on my docker desktop and now I want to run and use openmodelica on it, how could I do that?

for example, I have one simple example with openmodelca and want to test it with this docker, how?

Re: OpenModelica Docker Image available

Run the image:

docker run -d -p 25901:5901 -p 26901:6901 dersh/om-desktop-stable

Then, connect to the image using a web-browser by opening the URL. If you are running both on the same machine open this:

http://localhost:26901/vnc.html?password=headless

Then, click connect, and you should see a desktop in your browser.  Then, on the upper left of the desktop you should see "Applications"  Click that, then Development->OMEdit and you should see the OMEdit GUI and can run anything that you want.

Re: OpenModelica Docker Image available

thanks for your respond
but I want to use openmodelica from command not from GUI.
I mean want to use openmodelica and test my sample without GUI, just with image and command line.

Re: OpenModelica Docker Image available

You can just run the docker image without using the GUI (although it does still start some graphics stuff in the background). 
For example you can run a bash shell then use OMShell:

docker run -it dersh/om-desktop-stable /bin/bash

Then you can run:
OMShell-terminal


Or you can directly run omc.  For example to see the omc help you can do this:
docker run -it dersh/om-desktop-stable omc -h

There are 0 guests and 0 other users also viewing this topic
You are here: