Banbor2020 / openfoam-dockerfiles

This repo explains how to work with OpenFOAM through Docker. Using Docker has a number of advantages including a consistent working environment across different operating systems such as Windows, macOS and Linux. After having worked with Ubuntu, Debian, OpenSUSE, Windows (WSL), macOS and various HPC clusters, this is by far my favourite way working with OpenFOAM. Also, Microsoft Azure and Amazon AWS have support for Docker making it easy to deploy your setup on cloud solutions.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OpenFOAM Dockerfiles

This repository contains OpenFOAM Dockerfiles. I've included both openfoam.com and openfoam.org releases based on Ubuntu Focal (20.04 LTS).

What is Docker and why?

Docker is a set of tools to manage, build and run various software installations with a number of advantages. Using Docker we start containers (think of shipping containers)from images. Containers include everything needed to run a particular set of tasks (in this case OpenFOAM simulations). As containers are standardised, you can be confident that they run the same way on Windows, macOS and Linux. And yes, they are future proof and run similarly on major cloud solutions such as Amazon Web Services (AWS) and Microsoft Azure. This is convenient (!) because we can copy our setup to a cloud solution or a friend’s computer and still be confident it runs the same way.

Docker containers, Docker images and Dockerfiles

Instead of shipping the complete container including the operating system, it’s more convenient to use what we call Dockerfiles. Think of Dockerfiles as recipes (simply just text file with set of commands) that outlines how to build an image. A container may then be started from the Docker image

Setup

1. Prerequisites

a) Install Docker

Windows only: You will be prompted to install WSL (Windows Subsystem for Linux) when installing Docker (in the instructions please follow step 4 and 5).

b) Install Git

c) Install Paraview

2. Initial setup

a) Open a Powershell (Windows) or a terminal (macOS or Linux) and run the following commands to make a folder for your OpenFOAM data. This folder will store your simulation results:

mkdir $HOME/openfoam-data

b) Next, clone this repository by:

git clone https://github.com/jakobhaervig/openfoam-dockerfiles.git $HOME/openfoam-dockerfiles

c) Now, make sure Docker is running before running before continuing.

d) Build the OpenFOAM image, e.g. for OpenFOAM v2106:

docker image build -t openfoam:v2106 $HOME/openfoam-dockerfiles/v2106/

3. Running the Docker container

Finally, we can run a Docker container with /data mapped to $HOME/openfoam-data:

docker container run -ti --rm -v $HOME/openfoam-data:/data -w /data openfoam:v2106

Please note that everything in the container is deleted when you exit the container. Therefore you should save your simulation results and solver development in /data, which is the only directory that persists when the container is closed.

Running the above command should leave you inside the Docker container with the username "foam". Also, you may access the container through $HOME/openfoam-data e.g.:

On a Windows system: C:\Users\jakob\openfoam-data

On a macOS system: /Users/jakob/openfoam-data

On most Linux systems: /home/jakob/openfoam-data

About

This repo explains how to work with OpenFOAM through Docker. Using Docker has a number of advantages including a consistent working environment across different operating systems such as Windows, macOS and Linux. After having worked with Ubuntu, Debian, OpenSUSE, Windows (WSL), macOS and various HPC clusters, this is by far my favourite way working with OpenFOAM. Also, Microsoft Azure and Amazon AWS have support for Docker making it easy to deploy your setup on cloud solutions.


Languages

Language:Dockerfile 100.0%