Hey there,
It’s Robin from CFD Engine and this email is overdue.
Back when OpenFOAM v2106 came out, I picked the new Docker images as one of my highlights, but I reckoned that it would pass a lot of you by.
Judging by the download numbers on Docker Hub, I might’ve been right.
So, I thought I’d revisit it & let you know why I still think it’s a big deal & why you should take a look.
But first…
Docker?
Let me take a minute to give you an idea of what Docker is, what it does & why you might be interested.
Docker is an open-source suite of tools for downloading, managing, running & building software containers.
You can think of a container like an app – in this case it’s everything you need to run OpenFOAM, including any extra tools & libraries, all bundled into one big file (a container image).
Docker is the interface between the software in the container & your hardware. It runs things – managing which resources the containerised software can access (memory, CPU, storage etc) and keeping everything nicely isolated.
Unfortunately, to get the best out of it, you need to have a little Docker-knowledge & as we know “a little knowledge is a dangerous thing.”
The original official OpenFOAM Docker images tried to address this, but they didn’t quite work how people expected them to & caused plenty of confusion 🤯
In the v2106
release, ESI-OpenCFD revamped everything about their Docker image in an attempt to make it more user-friendly. This includes some behind-the-scenes changes to the container itself, but the more visible change is a new run script which abstracts away the Docker-knowledge & lets you get on with just FOAMing.
Good to go
If you’ve already got Docker on your machine, then it’s as simple as downloading the new openfoam-docker
script & making it executable – then you’re good to go (if not, you’ll need to grab Docker first).
You now have a choice on how to run the new script, for example:
openfoam-docker
will drop you into an interactive shell session with access to the files in your current directory & the fullv2106
OpenFOAM toolkit (the default OF version for this script).openfoam-docker -c './Allrun'
will run anAllrun
script in your current directory, usingv2106
.openfoam-docker -2012 -- blockMesh
will just runblockMesh
in the current directory usingv2012
(Docker will automatically download thev2012
container, if you don’t already have it).
As you can see, it’s a little different to using OpenFOAM in a native install, but not that different, especially if you’re using the interactive shell option.
You can run things in parallel (as you’d expect) & there’s barely any slowdown from running in Docker. Currently, the script allows you to choose from 2012
&/or 2106
OpenFOAM versions.
Beyond the script, there are a couple of other useful changes:
- There’s finally some decent documentation along with some help available in the script itself –
openfoam-docker -help
- All of the scripts &
Dockerfiles
that were used to build the images are available in their own repository. You can see how the images are built & even use them as the basis of your own tweaked/custom images.
Caveats
Don’t try running OpenFOAM in Docker on a cluster – it’s doable but it’s not a fun, beginner’s project.
If you’re developing/building code then it’s probably easier to do it outside a container. But, if you do want to give it a try, then Visual Studio Code has a neat workflow for developing inside containers.
You might want to check you can use Docker Desktop if you work for a big company.
Finally, don’t run GUI ParaView (or GUI anything) from a container, just use a native install, much quicker & easier (headless pvbatch
is quite happy in a container though) 👍
Conclusions
ESI-OpenCFD have done a great job of making their OpenFOAM Docker images more useful and more user-friendly.
So, if you tried the Docker images pre-v2106
& thought “nah, mate – not for me” then it could be worth taking a fresh look, especially if…
- you’re on a Mac;
- &/or you want an easy way to use multiple releases on a single machine;
- &/or you want a easy way to share a consistent CFD environment with your team/clients;
- or you want an alternative to running in the Linux shell on Windows.
If any of those sound like you, then I reckon you should take the new images for a spin, you might be pleasantly surprised – start here.
Let me know how you get on 🤞
Until next week, stay safe,