status of docker compatibility

A subforum specific to the development of the OpenFoam-based workbenches ( Cfd https://github.com/qingfengxia/Cfd and CfdOF https://github.com/jaheyns/CfdOF )

Moderator: oliveroxtoby

markrmau
Posts: 37
Joined: Fri Jan 03, 2020 4:03 am

status of docker compatibility

Post by markrmau »

Hi all,

I see that the mingw implementation of openfoam is the best solution for windows - it seems to work well.

I did some work a few years ago getting cfdof to use docker on linux / mac, but ran out of time to make it perfect and submit a pull request as I was trying to make it work on windows as well.

If I updated to make compatible with the latest cfdof & freecad 0.2, would a pull request be considered? Having the docker solution dedicated to linux/mac & leaving mingw for windows removes a few headaches.

Regards,
Mark
KAKM
Posts: 112
Joined: Tue May 04, 2021 12:17 am

Re: status of docker compatibility

Post by KAKM »

I'm not the person who would be approving that (or not), but I think whether that would be worthwhile depends on what your goals are. What is the benefit of docker over a native install on Linux/Mac? I used openfoam in docker on a mac for a while, and I found myself constantly having to shuffle files in and out as I was debugging my case. I have a native install now and I like it much better.
markrmau
Posts: 37
Joined: Fri Jan 03, 2020 4:03 am

Re: status of docker compatibility

Post by markrmau »

That's a good point.

When I last needed to use openfoam (about 2 years ago) I thought there was a recomendation to use the docker implementation to ensure all the libraries were compatible - I think there were a lot of compatibility issues at the time. It certainly is easier than compiling from source for some users.

I am using debian and the standard install is via docker. The changes I have makes cfdof work with the docker container like a native install.

However, since the mingw works on windows, and you can compile on linux/mac, maybe there isn't a need.
User avatar
oliveroxtoby
Posts: 837
Joined: Fri Dec 23, 2016 9:43 am
Location: South Africa

Re: status of docker compatibility

Post by oliveroxtoby »

markrmau wrote: Sat Oct 08, 2022 10:19 pm If I updated to make compatible with the latest cfdof & freecad 0.2, would a pull request be considered? Having the docker solution dedicated to linux/mac & leaving mingw for windows removes a few headaches.
If it works nicely then there's no reason not to have it as an option. Just be aware that you'd probably have to take on the job of keeping it maintained.
markrmau
Posts: 37
Joined: Fri Jan 03, 2020 4:03 am

Re: status of docker compatibility

Post by markrmau »

Shouldn't be a problem maintaining. Completed for linux / mac - I don't have a mac to test on though

https://github.com/mmcker/CfdOF

I haven't put in a pull request yet though - perhaps after some more testing.

This works by downloading the official openfoam docker image, adding the gmsh package, and running the container as a background process so a new container isn't started for each command. It keeps track of the running container and shuts it down at the end of the freecad session. Currently I'm using the paraview on the host computer (not the docker image paraview), but the docker image paraview could be made accessible if anyone needs this.

I think I could update this for the windows docker as well - but I'd have to look at what the previous issues were.

If anyone is available to test it would be much appreciated!
markrmau
Posts: 37
Joined: Fri Jan 03, 2020 4:03 am

Re: status of docker compatibility

Post by markrmau »

Linux/Mac: instructions
  • Install paraview on host machine. (eg sudo apt -y install paraview)
  • Make sure you have added your user to the docker group and logged out/in. Your non-root user needs to be able to control docker.
  • Install the mmcker version of CfdOF. ie - unzip the source so that this directory:

    Code: Select all

    ~/.local/share/FreeCAD/Mod/CfdOF 
    has the following: CfdOF (a directory), CHANGELOG.md, CONTRIBUTING.md, .......
  • Restart FreeCAD if already running
.
  • Go to Edit->Preferences->CfdOF
  • Enter a suitable OpenFOAM install directory (eg /home/USERNAME/OpenFOAM)
  • Select "Use docker" tickbox
  • Hit Install Docker. This will download & install the default openfoam v9 which i understand is the latest supported by CfdOF. The URL can be changed to try a different version.
  • Install cfmesh & HISA
  • Check dependencies
You should be up and running.

I am hoping to get it working under WSL2 (windows) next week - I don't think it will be too hard based on the linux implementation. My biggest concern is making sure there isn't a filesystem performance hit between the WSL and windows.

Cheers,
Mark
User avatar
oliveroxtoby
Posts: 837
Joined: Fri Dec 23, 2016 9:43 am
Location: South Africa

Re: status of docker compatibility

Post by oliveroxtoby »

markrmau wrote: Sun Oct 16, 2022 12:02 am Shouldn't be a problem maintaining. Completed for linux / mac - I don't have a mac to test on though

https://github.com/mmcker/CfdOF

I haven't put in a pull request yet though - perhaps after some more testing.

This works by downloading the official openfoam docker image, adding the gmsh package, and running the container as a background process so a new container isn't started for each command. It keeps track of the running container and shuts it down at the end of the freecad session. Currently I'm using the paraview on the host computer (not the docker image paraview), but the docker image paraview could be made accessible if anyone needs this.

I think I could update this for the windows docker as well - but I'd have to look at what the previous issues were.

If anyone is available to test it would be much appreciated!
Great. I don't have time to test this, but it doesn't look like there's much chance of it interfering with the other install methods, so you are welcome to make the pull request and we can see how it does in the wild if you would like.
markrmau
Posts: 37
Joined: Fri Jan 03, 2020 4:03 am

Re: status of docker compatibility

Post by markrmau »

Ok done! I have built and published a docker image which includes gmsh, cfmesh and hisa pre-compiled

You may wish to re-review as I have made significant changes. https://github.com/mmcker/CfdOF

[Edit] Now works with docker desktop on windows as well. Will automatically run either podman or docker.

Instructions for windows.
1. Install docker desktop or podman (a bit lighter than docker desktop)
https://github.com/containers/podman/re ... v4.2.1.msi
2. If podman installed: Init podman
podman machine init
3. If podman installed: Start podman
podman machine start
4. If podman installed: Set rootful
podman machine set --rootful
5. Edit -> Preferences -> CfdOF: Download & install paraview
6. Edit -> Preferences -> CfdOF: Select use docker.
7. Hit Download - you should then be ready to go. No need to download and install gmsh, cfmesh and HISA. They are all included in the image

Instructions for unix
1. Install docker
Like this or similar https://www.linuxtechi.com/install-dock ... on-debian/
2. Install paraview
eg sudo apt-get install paraview
3. Same as windows instructions 6,7


Next steps:
2. Revisit the mapping of the windows c folder to the linux docker folder - to ensure we have best file transfer speed
3. Update the readme for usedocker instructions
4. If this implementation works and everyone agrees, remove the old windows docker code.
markrmau
Posts: 37
Joined: Fri Jan 03, 2020 4:03 am

Re: status of docker compatibility

Post by markrmau »

markrmau wrote: Thu Oct 20, 2022 11:35 pm 2. Revisit the mapping of the windows c folder to the linux docker folder - to ensure we have best file transfer speed
I have made some more changes to address this issue.

Unfortunately the fast filesystem integration is only available with podman - docker doesn't seem to provide a home directory for the user in wsl$ folder like podman does. I'm sure there is a solution but will need to look at it. I think just stick with podman for now.

To use the fast wsl integration, install, initialise and start podman as before.

Then create a new subdirectory under this one created by podman: \\wsl$\podman-machine-default\home\user

For example, I created: \\wsl$\podman-machine-default\home\user\cfdof

Then in cfdof set the default output directory as above: \\wsl$\podman-machine-default\home\user\cfdof

For my simple test case this made a noticable speed improvement.

If any windows users are able to test I'm sure it would be appreciated. It is easy to download a zip file from here: https://github.com/mmcker/CfdOF/archive ... master.zip

And extract to your local machine to test it (so the directory below has the folder CfdOF)
C:\Users\*username*\AppData\Roaming\FreeCAD\Mod
User avatar
adrianinsaval
Veteran
Posts: 5548
Joined: Thu Apr 05, 2018 5:15 pm

Re: status of docker compatibility

Post by adrianinsaval »

markrmau wrote: Sat Oct 22, 2022 4:25 am If any windows users are able to test I'm sure it would be appreciated. It is easy to download a zip file from here: https://github.com/mmcker/CfdOF/archive ... master.zip
I get this error when trying to open the preferences page with your version:

Code: Select all

14:29:08  Traceback (most recent call last):
14:29:08    File "C:\Users\username\AppData\Roaming\FreeCAD\Mod\CfdOF-master\.\CfdOF\CfdPreferencePage.py", line 122, in __init__
14:29:08      CfdTools.docker_container = CfdTools.DockerContainer()
14:29:08    File "C:\Users\username\AppData\Roaming\FreeCAD\Mod\CfdOF-master\.\CfdOF\CfdTools.py", line 1741, in __init__
14:29:08      self.docker_cmd = self.docker_cmd.split(os.path.sep)[-1]
14:29:08  AttributeError: 'NoneType' object has no attribute 'split'
14:29:08  CfdPreferencePage is not a preference page
Post Reply