Precompiled packages (Docker)
Quick-start:
If docker is already installed and setup, simply download the
openfoam-docker script and run it.
Post-process with the native ParaView, for better performance and easy configuration. Do not bother with the paraFoam script.
The packages do not contain
visualization (eg, ParaView/runTimePostProcessing) or
external-solver (eg, PETSc) modules:
see the corresponding FAQ
Docker
OpenCFD Ltd. uses Docker Hub to distribute container images with pre-packaged, pre-compiled versions of OpenFOAM for Linux, Mac OSX and Windows. There are a variety of image flavours available:
-
-run
: a small-footprint runtime-only image -
-dev
: runtime with OpenFOAM development environment -
-default
: just-give-me-everything image
Containers allow binaries compiled on a given platform to run on other platforms (Linux, Windows, OSX) without significant degradation in performance. For data centres, containers are an attractive means of encapsulating applications.
About the image
The current images uses the latest Ubuntu LTS version and are created following recipes similar or identical to those given in the corresponding packaging/containers files.
- If you need to install any additional tools temporarily in your docker container, start it as usual via the openfoam-docker script. Additional information about sudo is available within the container (follow the welcome banner for local help).
- If you need install any tools permanently in your docker image, use one of the docker files from the packaging/containers repository as a template for creating your own custom images.
Running OpenFOAM in a container
-
Download the openfoam-docker run script and place it somewhere convenient in your path (eg,
$HOME/bin
etc) -
Make the script executable, and set links to some preferred OpenFOAM versions and image flavours. For example,
$ chmod +x openfoam-docker $ ln -sf openfoam-docker openfoam2112-run
-
Verify that the script (or link) can be executed, and take a look at some of the available options:
$ openfoam-docker -help $ openfoam-docker -help-full
-
Use the
-dry-run
option if you want to see how the script actually calls docker, without actually running anything.$ openfoam-docker -dry-run
The downloaded openfoam-docker run script is the recommended means to enter the OpenFOAM image. Assuming that a corresponding link has been made, calling it without any arguments will bind in the local directory and start the image with an OpenFOAM environment. Eg,
$ openfoam2112-run
This will open an interactive shell with the OpenFOAM environment active, with the current local directory mounted within the container.
Note: The first time the script is executed, it will take a bit longer to start, since it also needs to download the Docker Hub image.
Running interactively
Running an interactive shell with the OpenFOAM environment active is the default behaviour for the image and run-script.
For example,
$ openfoam-docker
# With a different OpenFOAM version:
$ openfoam-docker -2012
Running non-interactively
It is also possible to use the image in batch mode. The key is to
ensure that the run-script understands where the commands begin.
For this, the standard --
or -
separators can be used, but a
single isolated /
also works and provides a nice visual separation.
For example,
$ openfoam-docker / blockMesh -help
It is also possible to use the run-script to run shell scripts. For example,
$ openfoam-docker -c './Allrun'
Note that the entry point within the image itself also has some option handling. For example,
$ openfoam-docker / -help
Installing Docker
- Get and install docker: https://docs.docker.com/engine/install/
- Setup docker user: https://docs.docker.com/engine/install/linux-postinstall/
Some possible commands after installing (Linux only):
Command | Comment |
---|---|
$ id |
Check that the user belongs to the docker group |
$ sudo /usr/sbin/usermod -aG docker $(whoami) |
Add current user to the docker group |
$ docker info |
Verify the docker daemon is actually running |
$ docker images |
List local images |
Frequently Asked Questions
-
Is there any performance degradation when running via Docker?
On Linux it should run as quickly as natively hosted code. On Windows and OSX there is a slight performance penalty, largely related to I/O. -
Why is slow on ARM-based machines?
Since the standard docker images are AMD64-based, the AMD64 emulation layer is cause of the slowdown here. If you just want to test a few commands this probably will not bother you, but if you want to use OpenFOAM more extensively you need an ARM64-based image. See next question. -
Can I rebuild my own image?
This is no problem. All of the files needed are provided on the packaging/containers repository.
If you have an ARM-based machine, you should use the openSUSE Leap components (see the openfoam-run_leap.Dockerfile from the repo). The standard images are usually AMD64 Ubuntu images and the Ubuntu OpenFOAM packages for ARM may be outdated or missing. However, the OpenFOAM ARM packages for openSUSE Leap are fully aligned. -
Can I reuse the docker images?
That is the beauty of containers. Simply start from any given image (include these OpenFOAM images) and define your own layers. -
How do I check if the OpenFOAM image has been downloaded correctly?
The command$ docker images
shows the local images available. For example,
REPOSITORY TAG IMAGE ID CREATED SIZE opencfd/openfoam2112-run latest xxxxxxxxxxxx N days ago 640MB opencfd/openfoam2112-dev latest xxxxxxxxxxxx N days ago 1.38GB ...
If you receive an error message about not being able to contact the Docker daemon check that the Docker daemon is started at boot time and that the user account is in the docker group (see output from
id
command). -
I prefer to use podman instead of docker
No worries, asopenfoam-docker -help-full
shows, that option is also available:$ openfoam-docker -podman
-
Where are my files?
The user files inside Docker are visible (ie, mounted) in your home area and can be operated on just like any other file. -
Why doesn't
paraFoam
display?
We previously had a long answer here about X-windows access etc, but in our experience it is simply not worth running paraview within the docker image. It is much simpler and has better performance to run ParaView natively on the host operating systems directly. Use the built-in OpenFOAM reader and/or OpenFOAM data conversion tools such asfoamToVTK
. -
How do I run parallel?
Same as any other OpenFOAM installation, e.g.:mpirun -np 2 icoFoam -parallel
-
How do I run parallel on multiple computers?
This is not trivial inside the Docker environment. Also you might want to include optimised communication libraries (MPI) so it probably makes more sense to perform a native compilation -
How do I compile code?
There are various docker images available, if you use the-dev
or-default
versions, they contains a full OpenFOAM development environment so allwmake
,wclean
etc. commands work (it is running the actual environment OpenFOAM was compiled in!) -
Program XYZ is missing in the container, how do I install it?
Follow the information in the welcome banner (local help) for managing sudo. Any programs installed within the container will disappear after the container is destroyed. If you have programs that you believe absolutely must be installed (but maybe only for you), you can simply create your own docker images on top of those provided from OpenCFD.
Copyright (C) 2020-2022 OpenCFD Ltd.