{"id":16569000,"url":"https://github.com/jakobhaervig/openfoam-dockerfiles","last_synced_at":"2026-03-27T03:43:56.013Z","repository":{"id":38206228,"uuid":"316953490","full_name":"jakobhaervig/openfoam-dockerfiles","owner":"jakobhaervig","description":"This repo explains how to work with OpenFOAM through Docker. This ensures a consistent working environment across different operating systems such as Windows, macOS and Linux, which is convenient when working in groups.","archived":false,"fork":false,"pushed_at":"2024-06-09T16:59:24.000Z","size":203,"stargazers_count":26,"open_issues_count":0,"forks_count":15,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-27T13:19:07.151Z","etag":null,"topics":["computational-fluid-dynamics","containers","docker","openfoam"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jakobhaervig.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-29T13:08:27.000Z","updated_at":"2025-01-30T21:28:50.000Z","dependencies_parsed_at":"2024-06-09T18:20:04.328Z","dependency_job_id":null,"html_url":"https://github.com/jakobhaervig/openfoam-dockerfiles","commit_stats":{"total_commits":121,"total_committers":5,"mean_commits":24.2,"dds":0.4545454545454546,"last_synced_commit":"5f0b2fa05540712443ac82cacaad11956f870394"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakobhaervig%2Fopenfoam-dockerfiles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakobhaervig%2Fopenfoam-dockerfiles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakobhaervig%2Fopenfoam-dockerfiles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakobhaervig%2Fopenfoam-dockerfiles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jakobhaervig","download_url":"https://codeload.github.com/jakobhaervig/openfoam-dockerfiles/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243830912,"owners_count":20354848,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computational-fluid-dynamics","containers","docker","openfoam"],"created_at":"2024-10-11T21:12:10.098Z","updated_at":"2026-03-27T03:43:50.983Z","avatar_url":"https://github.com/jakobhaervig.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenFOAM Dockerfiles\n\nThis repository contains OpenFOAM Dockerfiles. Both openfoam.com and openfoam.org releases are included. Both are based on a recent Ubuntu image.\n\n### What is Docker and why?\n\nDocker 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.\n\n### Docker containers, Docker images and Dockerfiles\n\nInstead 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\n\n### Contributing to this project\n\nFeel free to fork these Docker files. If you make an improvement you are most welcome to make a pull request and you will be added to the author list. Comments are also welcome.\n\n# Setup\nThis guide explains how to setup OpenFOAM with Docker. It contains both OpenFOAM fundation releases (from openfoam.org) and OpenFOAM ESI releases (from openfoam.com).\n\n## 1. Prerequisites\n*1a)* Install [Docker](https://www.docker.com/products/docker-desktop)\n\nWindows only: You will be prompted to install WSL (Windows Subsystem for Linux) when installing Docker (in the instructions\nplease follow step 4 and 5).\n\n*1b)* Install [Git](https://git-scm.com/downloads) for your operating system (Windows, macOS or Linux)\n\n*1c)* Install the latest [Paraview](https://www.paraview.org/download/) version. If you have trouble getting the MPI version (parallel) to work, please choose the non-MPI version.\n\nWindows only: Choose the .exe or .msi file\n\nmacOS: Choose the .pkg file\n\nLinux: Choose the .tar.gz archieve and extract it\n\n## 2. Preparing for OpenFOAM\n*2a)* Decide on a OpenFOAM version to install. List available versions by folder names in this repository. Following the steps in guide will give you the latest ESI release of OpenFOAM. Replace ```esi``` with ```foundation``` to install the latest foundation release (e.g. 7, 8, 9)\n\n*2b)* Open a Powershell (Windows) or a terminal (macOS or Linux) and run the following commands. First, make a folder to store your OpenFOAM data:\n\n```shell\nmkdir $HOME/openfoam-data\n```\n\n*2c)* Next, clone this repository by:\n\n```shell\ngit clone https://github.com/jakobhaervig/openfoam-dockerfiles.git $HOME/openfoam-dockerfiles\n```\n\nYou should now have two folder ```openfoam-data``` and ```openfoam-dockerfiles``` in your home folder.\n\n*2d)* Now, start the program called Docker Desktop to start the Docker engine.\n\n*2e)* Build the OpenFOAM image:\n\n```shell\ndocker image build --no-cache -t openfoam $HOME/openfoam-dockerfiles/esi/latest/\n```\n\n## 3. Run the Docker container\n\n*3a)* Finally, start a Docker container with ``/data`` mapped to ``$HOME/openfoam-data``:\n\n```shell\ndocker container run -ti --rm -v $HOME/openfoam-data:/data -w /data openfoam:latest\n```\n\nNote: All files stored in the container are 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.\n\nRunning the above command should leave you inside the Docker container with the username ```foam```. \n\n## 4. Accessing files in the Docker container\n\nYou may access the container through ``$HOME/openfoam-data`` e.g.:\n\nOn a Windows system: ``C:\\Users\\jakob\\openfoam-data``\n\nOn a macOS system: ``/Users/jakob/openfoam-data``\n\nOn most Linux systems: ``/home/jakob/openfoam-data``\n\n## 5. Optional: Save an alias for running the Docker container\nInstead of starting a Docker container with the command in [3. Run the Docker container](#3-run-the-docker-container), we can save an alias for that command. With an alias saved we can simply type ```of``` (short for OpenFOAM) in a Powershell (Windows) or a terminal (macOS or Linux) to start the Docker container.\n\n### **Windows operating system**\n*5a)* Open a Powershell with *Administrator Rights* and enter the follwing commands (copy/paste the code from each step into the Power Shell (use GitHub's copy buttom) and hit enter).\n\n*5b)* Allow scripts to be run (Hit *A* for Yes to All):\n```shell\nSet-ExecutionPolicy RemoteSigned\n```\n\n*5c)* Create a ```profile``` file to store our alias function:\n```shell\nNew-Item -Path $profile -ItemType file -force\n```\n\n*5d)* Add the alias to the newly created file:\n```shell\necho \"function openfoam-docker-latest {docker container run -ti --rm -v $HOME/openfoam-data:/data -w /data openfoam:latest} Set-Alias of openfoam-docker-latest\" \u003e $profile\n```\n\nWe can now start the container using the newly created ```of``` alias by typing ```of``` in the Power Shell.\n\n### **macOS and Linux systems**\n*5a)* \nCopy/paste the following code snippet in the terminal:\n```shell\ncase \"$OSTYPE\" in\n  linux*)   echo \"alias of='docker container run -ti --rm -v $HOME/openfoam-data:/data -w /data openfoam:latest'\" \u003e\u003e $HOME/.bashrc ;;\n  darwin*)  echo \"alias of='docker container run -ti --rm -v $HOME/openfoam-data:/data -w /data openfoam:latest'\" \u003e\u003e $HOME/.zprofile ;;\n  *)        echo \"This function is not yet added for $OSTYPE\" ;;\nesac\n```\n\nAfter opening a new terminal, we can now start the container using the newly created ```of``` alias by typing ```of``` in the Power Shell.\n\n## 6. Install extensions\nIf you need to add extensions to your image, you may extend it by following the steps below. \n\n*6a)* To extend our Docker image to include a Python installation with different useful packages:\n\n```shell\ndocker image build -t openfoam $HOME/openfoam-dockerfiles/extensions/python\n```\n\n*6b)* To extend our Docker image to include a FreeCad installation:\n\n```shell\ndocker image build -t openfoam $HOME/openfoam-dockerfiles/extensions/freecad\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakobhaervig%2Fopenfoam-dockerfiles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjakobhaervig%2Fopenfoam-dockerfiles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakobhaervig%2Fopenfoam-dockerfiles/lists"}