Ask.Cyberinfrastructure

How do I create a docker container for OpenFOAM-1.6-ext

Hi,

I would like to create a docker container for OpenFOAM-1.6-ext. I couldn’t find an image of OpenFOAM-1.6-ext on dockerhub so I decided to create a Dockerfile my own. A screenshot of my Dockerfile is attached. I followed the OpenFOAM installation steps listed: here. After I issued the command: sudo docker build -t “openfoam-1.6-ext:docker”, I received an error message stating “cp: cannot stat ‘etc/prefs.sh-EXAMPLE’: No such file or directory”. Does anyone know what I did wrong?

Thanks,
Wensi

Hey Wensi! I saw you post to the Singularity list. Did you see this post:

And it wasn’t helpful for you? I would like to offer to take a look at your recipe - could you copy paste the actual code into a text code block so I can see?

Ah, so to give you a quick example, I can confirm that the file in question does exist in the repository you are cloning:

But since you are putting the command into different RUN sections, you are likely in the wrong working directory. Instead, you will want to put all of those RUN statements into one command, here is a start:

RUN git clone https://github.com/Unofficial-Extend-Project-Mirror/openfoam-extend-OpenFOAM-1.6-ext.git OpenFOAM-1.6-ext && \
    cd OpenFOAM-1.6-ext && \
    git checkout 1.6.1 -b 16ext && \
    cp etc/prefs.sh-EXAMPLE etc/prefs.sh && \
    # do this for the remainder of your lines.

If you wanted to do something like the above (with multiple RUN statements, each coinciding with a Docker layer which isn’t best practice) You would want to clone the repository with one RUN, and then set the WORKDIR to be the repository.

RUN git clone https://github.com/Unofficial-Extend-Project-Mirror/openfoam-extend-OpenFOAM-1.6-ext.git OpenFOAM-1.6-ext
WORKDIR OpenFOAM-1.6-ext

Does that make sense?

Hi Vanessa!

I read the post you sent regarding to running openfoam on an HPC resource; it was really helpful. Right now I’m trying to create a docker image, push it to docker hub, and then convert it to singularity container. I’ve tried your suggestion of putting all RUN statements into one command and played with WORKDIR a bit:

FROM ubuntu:18.04
MAINTAINER Wensi Wu<wensi.wu.w@gmail.com>

ENV DEBIAN_FRONTEND=noninteractive

WORKDIR /home/wensi

RUN apt-get -q update && \
    apt-get -q -y upgrade && \
    apt-get -q -y install git flex rpm build-essential zlib1g-dev binutils-dev && \
    apt-get -q -y install openmpi-bin libopenmpi-dev cmake paraview libstdc++5 libiberty-dev && \
    apt-get -q update && \
    mkdir OpenFOAM && \
    cd OpenFOAM && \
    git clone https://github.com/Unofficial-Extend-Project-Mirror/openfoam-extend-OpenFOAM-1.6-ext.git OpenFOAM-1.6-ext && \
    export HOME=/home/wensi && \
    cd OpenFOAM-1.6-ext && \
    git checkout 1.6.1 -b 16ext && \
    cp etc/prefs.sh-EXAMPLE etc/prefs.sh && \
    echo "export WM_COMPILER=Gcc54" >> etc/prefs.sh && \
    sed -i s/"#export WM_MPLIB=SYSTEMOPENMPI"/"export WM_MPLIB=SYSTEMOPENMPI"/g etc/prefs.sh && \
    sed -i s/"#export OPENMPI_DIR=path_to_system_installed_openmpi"/"export OPENMPI_DIR=\/usr"/g etc/prefs.sh && \
    sed -i s/"^#export OPENMPI_BIN_DIR"/"export OPENMPI_BIN_DIR"/g etc/prefs.sh && \
    sed -i s/"#export PARAVIEW_SYSTEM=1"/"export PARAVIEW_SYSTEM=1"/g etc/prefs.sh && \
    sed -i s/"#export PARAVIEW_DIR=path_to_system_installed_paraview"/"export PARAVIEW_DIR=\/usr"/g etc/prefs.sh && \
    sed -i s/"^#export PARAVIEW_BIN_DIR"/"export PARAVIEW_BIN_DIR"/g etc/prefs.sh && \
    echo "export WM_NCOMPPROCS=4" >> etc/prefs.sh && \
    sed -i -e 's=\.OpenFOAM=\.foam=' bin/paraFoam && \
    sed -i -e 's/^unset/export LC_ALL=C; unset/' bin/paraFoam && \
    ln -s /usr/bin/make bin/gmake && \
    sed -i -e 's=\(U_WIN32\)$=\1 -DENGINE=g' applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/Make/tecioOptions && \
    sed -i -e 's=software.sandia.gov/~jakraft=downloads.sourceforge.net/project/openfoam-extend/foam-extend-3.0/ThirdParty=g' ThirdParty/AllMake.stage3 ThirdParty/rpmBuild/SPECS/mesquite-2.1.2.spec && \
    find src applications -name "*.L" -type f | xargs sed -i -e 's=\(YY\_FLEX\_SUBMINOR\_VERSION\)=YY_FLEX_MINOR_VERSION < 6 \&\& \1=' && \
    cp -r wmake/rules/linux64Gcc46 wmake/rules/linux64Gcc54 && \
    sed -i 's/^\(c++FLAGS.*\)/\1 -fpermissive/g' wmake/rules/linux64Gcc54/c++ && \
    . etc/bashrc && \
    cd ThirdParty && \
    sed -i 's=^( rpm_make -p cmake=#( rpm_make -p cmake=' AllMake.stage1 && \
    sed -i -e 's/\(\+.*LIBS = \)/\1-Xlinker --add-needed -Xlinker --no-as-needed /' ./rpmBuild/SOURCES/ParMGridGen-1.0.patch && \
    sed -i -e 's/\(\+.*LIBS = \)/\1-Xlinker --add-needed -Xlinker --no-as-needed /' ./rpmBuild/SOURCES/ParMetis-3.1.1.patch && \
    sed -i -e 's=$(LDFLAGS)=$(LDFLAGS) -pthread=' ./rpmBuild/SOURCES/scotch-5.1.10b_patch_0 && \
    ./AllMake > log.AllMake 2>&1 && \
    cd .. && \
    . etc/bashrc && \
    ./Allwmake > log.AllwMake 2>&1

When I tried to build the docker file, it stalled at line ". etc/bashrc && " before "cd ThirdParty && ". It seems like it was having trouble accessing to ThirdParty directory.

Thank you so much for your help!

Wensi

I have OpenFOAM-1.6-ext installed and built on my ubuntu. Can I create a docker image for the already built OpenFOAM? Would that be easier?

heya @ww382! I think you are close! To answer your question, it’s not really possible to just move an installation on your host into the container. Give me a few minutes with your recipe and I’ll see if I can make a version for you that works.

Okay, this seems to work to install in Docker. It’s a weird package because it expects a very particular path structure (installing to the user’s home) and that gets more weird with Docker having home as /root. This compiles and finishes ok, however if you need to bring it over to HPC and convert to Singularity you’ll have trouble with everything being in root’s home. If that happens, what we can do is give permissions to some openfoam user in the container, and then install in openfoam’s home and make it accessible to others. For now, give this a go:

FROM ubuntu:18.04

# docker build -t wensi/openfoam .

LABEL MAINTAINER Wensi Wu<wensi.wu.w@gmail.com>
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get -q update && \
    apt-get -q -y upgrade && \
    apt-get -q -y install git flex rpm build-essential zlib1g-dev binutils-dev && \
    apt-get -q -y install openmpi-bin libopenmpi-dev cmake paraview libstdc++5 libiberty-dev && \
    apt-get -q update

WORKDIR /root

RUN mkdir -p OpenFOAM && \
    cd OpenFOAM && \
    git clone https://github.com/Unofficial-Extend-Project-Mirror/openfoam-extend-OpenFOAM-1.6-ext.git OpenFOAM-1.6-ext

WORKDIR /root/OpenFOAM/OpenFOAM-1.6-ext

RUN git checkout 1.6.1 -b 16ext && \
    cp etc/prefs.sh-EXAMPLE etc/prefs.sh && \
    echo "export WM_COMPILER=Gcc54" >> etc/prefs.sh && \
    sed -i s/"#export WM_MPLIB=SYSTEMOPENMPI"/"export WM_MPLIB=SYSTEMOPENMPI"/g etc/prefs.sh && \
    sed -i s/"#export OPENMPI_DIR=path_to_system_installed_openmpi"/"export OPENMPI_DIR=\/usr"/g etc/prefs.sh && \
    sed -i s/"^#export OPENMPI_BIN_DIR"/"export OPENMPI_BIN_DIR"/g etc/prefs.sh && \
    sed -i s/"#export PARAVIEW_SYSTEM=1"/"export PARAVIEW_SYSTEM=1"/g etc/prefs.sh && \
    sed -i s/"#export PARAVIEW_DIR=path_to_system_installed_paraview"/"export PARAVIEW_DIR=\/usr"/g etc/prefs.sh && \
    sed -i s/"^#export PARAVIEW_BIN_DIR"/"export PARAVIEW_BIN_DIR"/g etc/prefs.sh && \
    echo "export WM_NCOMPPROCS=4" >> etc/prefs.sh && \
    sed -i -e 's=\.OpenFOAM=\.foam=' bin/paraFoam && \
    sed -i -e 's/^unset/export LC_ALL=C; unset/' bin/paraFoam && \
    ln -s /usr/bin/make bin/gmake && \
    sed -i -e 's=\(U_WIN32\)$=\1 -DENGINE=g' applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/Make/tecioOptions && \
    sed -i -e 's=software.sandia.gov/~jakraft=downloads.sourceforge.net/project/openfoam-extend/foam-extend-3.0/ThirdParty=g' ThirdParty/AllMake.stage3 ThirdParty/rpmBuild/SPECS/mesquite-2.1.2.spec && \
    find src applications -name "*.L" -type f | xargs sed -i -e 's=\(YY\_FLEX\_SUBMINOR\_VERSION\)=YY_FLEX_MINOR_VERSION < 6 \&\& \1=' && \
    cp -r wmake/rules/linux64Gcc46 wmake/rules/linux64Gcc54 && \
    sed -i 's/^\(c++FLAGS.*\)/\1 -fpermissive/g' wmake/rules/linux64Gcc54/c++ && \
    . etc/bashrc && \
    cd ThirdParty && \
    sed -i 's=^( rpm_make -p cmake=#( rpm_make -p cmake=' AllMake.stage1 && \
    sed -i -e 's/\(\+.*LIBS = \)/\1-Xlinker --add-needed -Xlinker --no-as-needed /' ./rpmBuild/SOURCES/ParMGridGen-1.0.patch && \
    sed -i -e 's/\(\+.*LIBS = \)/\1-Xlinker --add-needed -Xlinker --no-as-needed /' ./rpmBuild/SOURCES/ParMetis-3.1.1.patch && \
    sed -i -e 's=$(LDFLAGS)=$(LDFLAGS) -pthread=' ./rpmBuild/SOURCES/scotch-5.1.10b_patch_0 && \
    ./AllMake > log.AllMake && \
    cd .. && \
    . etc/bashrc && \
    ./Allwmake > log.AllwMake

I removed the bit that silences the printing of the comple to stdout, and also If you want to make the container flexible to future version changes you can add:

ENV OPENFOAM_BRANCH=1.6.1
ENV OPENFOAM_VERSION=1.6-ext

And then replace those throughout the file where they are needed. It’s still compiling for me locally so likely I’ll be updating the recipe with a change to the path (and I want to test that it works too) but this should at least give you something to start with.

Thank you so so so much @vsoch! :slight_smile:

Sure thing! I had some trouble above with the install to root, so I’m refactoring now to change to an openfoam user. If I have luck I’ll share!

I was getting error messages like:

/usr/bin/ld: cannot find -lfiniteVolume 
/usr/bin/ld: cannot find -ldynamicMesh 
/usr/bin/ld: cannot find -lmeshTools

Yes this looks like not having libraries on LD_LIBRARY_PATH or needing to run ldconfig - I also noticed we are using an 18.04 base and the instructions are for 16.04 so I’m trying that too, along with installing as the openfoam user. Man this takes forever to compile!

I just hit these too (installing as openfoam user):

/usr/bin/ld: cannot find -lincompressibleTransportModels
/usr/bin/ld: cannot find -lincompressibleRASModels
/usr/bin/ld: cannot find -lbasicThermophysicalModels
/usr/bin/ld: cannot find -lcompressibleRASModels
/usr/bin/ld: cannot find -lfiniteVolume
/usr/bin/ld: cannot find -lmeshTools
/usr/bin/ld: cannot find -lsampling

I think I just stumbled on what might be the issue - when I shelled in and looked in the ThirdParty folder, there were no RPMS in the source directory. If I ran the AllMake again, it doesn’t issue an actual error, but it’s riddled with “Cannot find xxxx.rpm.” If we scroll up a little more, there is a message of missing wget :slight_smile: So - I installed wget (as root) and now the ThirdParty libraries are actually compiling! I’ll post an update if/when I get through this bug.

okay I think it’s good! I was able to run icoFoam, and although the help text appears different than in the interface, it seems to work. @ww382 you likely have experience using this and can give the final say - here is the recipe that worked for me (notice wget added to the top):

FROM ubuntu:16.04

# docker build -t wensi/openfoam .

LABEL MAINTAINER Wensi Wu<wensi.wu.w@gmail.com>
ENV DEBIAN_FRONTEND=noninteractive
ENV OPENFOAM_BRANCH=1.6.1

RUN apt-get -q update && \
    apt-get -q -y install git flex rpm build-essential zlib1g-dev binutils-dev && \
    apt-get -q -y install openmpi-bin libopenmpi-dev cmake paraview libstdc++5 libiberty-dev wget

RUN useradd -ms /bin/bash openfoam
WORKDIR /home/openfoam
USER openfoam

RUN mkdir -p OpenFOAM && \
    cd OpenFOAM && \
    git clone https://github.com/Unofficial-Extend-Project-Mirror/openfoam-extend-OpenFOAM-1.6-ext.git OpenFOAM-1.6-ext

WORKDIR /home/openfoam/OpenFOAM/OpenFOAM-1.6-ext

RUN git checkout 1.6.1 -b 16ext && \
    cp etc/prefs.sh-EXAMPLE etc/prefs.sh && \
    echo "export WM_COMPILER=Gcc54" >> etc/prefs.sh && \
    sed -i s/"#export WM_MPLIB=SYSTEMOPENMPI"/"export WM_MPLIB=SYSTEMOPENMPI"/g etc/prefs.sh && \
    sed -i s/"#export OPENMPI_DIR=path_to_system_installed_openmpi"/"export OPENMPI_DIR=\/usr"/g etc/prefs.sh && \
    sed -i s/"^#export OPENMPI_BIN_DIR"/"export OPENMPI_BIN_DIR"/g etc/prefs.sh && \
    sed -i s/"#export PARAVIEW_SYSTEM=1"/"export PARAVIEW_SYSTEM=1"/g etc/prefs.sh && \
    sed -i s/"#export PARAVIEW_DIR=path_to_system_installed_paraview"/"export PARAVIEW_DIR=\/usr"/g etc/prefs.sh && \
    sed -i s/"^#export PARAVIEW_BIN_DIR"/"export PARAVIEW_BIN_DIR"/g etc/prefs.sh && \
    echo "export WM_NCOMPPROCS=4" >> etc/prefs.sh && \
    sed -i -e 's=\.OpenFOAM=\.foam=' bin/paraFoam && \
    sed -i -e 's/^unset/export LC_ALL=C; unset/' bin/paraFoam && \
    ln -s /usr/bin/make bin/gmake && \
    sed -i -e 's=\(U_WIN32\)$=\1 -DENGINE=g' applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/Make/tecioOptions && \
    sed -i -e 's=software.sandia.gov/~jakraft=downloads.sourceforge.net/project/openfoam-extend/foam-extend-3.0/ThirdParty=g' ThirdParty/AllMake.stage3 ThirdParty/rpmBuild/SPECS/mesquite-2.1.2.spec && \
    find src applications -name "*.L" -type f | xargs sed -i -e 's=\(YY\_FLEX\_SUBMINOR\_VERSION\)=YY_FLEX_MINOR_VERSION < 6 \&\& \1=' && \
    cp -r wmake/rules/linux64Gcc46 wmake/rules/linux64Gcc54 && \
    sed -i 's/^\(c++FLAGS.*\)/\1 -fpermissive/g' wmake/rules/linux64Gcc54/c++ && \
    . etc/bashrc && \
    cd ThirdParty && \
    sed -i 's=^( rpm_make -p cmake=#( rpm_make -p cmake=' AllMake.stage1 && \
    sed -i -e 's/\(\+.*LIBS = \)/\1-Xlinker --add-needed -Xlinker --no-as-needed /' ./rpmBuild/SOURCES/ParMGridGen-1.0.patch && \
    sed -i -e 's/\(\+.*LIBS = \)/\1-Xlinker --add-needed -Xlinker --no-as-needed /' ./rpmBuild/SOURCES/ParMetis-3.1.1.patch && \
    sed -i -e 's=$(LDFLAGS)=$(LDFLAGS) -pthread=' ./rpmBuild/SOURCES/scotch-5.1.10b_patch_0 && \
    ./AllMake > log.AllMake && \
    cd .. && \
    . etc/bashrc && \
    ./Allwmake > log.AllwMake && \
    ./Allwmake

That was fun :slight_smile:

1 Like

Thanks, @vsoch! I’ll give you an update! :slight_smile:

I pull the openfoam image from Docker Hub

singularity pull --name OpenFOAM-1.6-ext.simg docker://ww382/openfoam

Then shell into the image

singularity shell OpenFOAM-1.6-ext.simg 

I encountered some permission issues, so I created a recipe file for Singularity:

Bootstrap: docker
From: docker://ww382/openfoam

%environment
  export SHELL=/bin/bash
  export PATH=/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/ThirdParty/packages/scotch-5.1.10b/platforms/linux64Gcc54DPOpt/bin:/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/ThirdParty/packages/mesquite-2.1.2/platforms/linux64Gcc54DPOpt/bin:/usr/bin:/home/openfoam/OpenFOAM/openfoam-1.6-ext/applications/bin/linux64Gcc54DPOpt:/home/openfoam/OpenFOAM/site/1.6-ext/bin/linux64Gcc54DPOpt:/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/applications/bin/linux64Gcc54DPOpt:/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/wmake:/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
  export LD_LIBRARY_PATH=/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/ThirdParty/packages/scotch-5.1.10b/platforms/linux64Gcc54DPOpt/lib:/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/ThirdParty/packages/ParMGridGen-1.0/platforms/linux64Gcc54DPOpt/lib:/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/ThirdParty/packages/ParMetis-3.1.1/platforms/linux64Gcc54DPOpt/lib:/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/ThirdParty/packages/metis-5.0pre2/platforms/linux64Gcc54DPOpt/lib:/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/ThirdParty/packages/mesquite-2.1.2/platforms/linux64Gcc54DPOpt/lib:/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/lib/linux64Gcc54DPOpt/openmpi-system:/usr/lib/x86_64-linux-gnu/openmpi/lib:/usr//lib:/home/openfoam/OpenFOAM/openfoam-1.6-ext/lib/linux64Gcc54DPOpt:/home/openfoam/OpenFOAM/site/1.6-ext/lib/linux64Gcc54DPOpt:/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/lib/linux64Gcc54DPOpt:/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/lib/linux64Gcc54DPOpt/dummy
  export FOAM_APP=/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/applications
  export FOAM_APPBIN=/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/applications/bin/linux64Gcc54DPOpt
  export FOAM_INST_DIR=/home/openfoam/OpenFOAM
  export FOAM_JOB_DIR=/home/openfoam/OpenFOAM/jobControl
  export FOAM_LIBBIN=/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/lib/linux64Gcc54DPOpt
  export FOAM_MPI=/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/lib/linux64Gcc54DPOpt/openmpi-system
  export FOAM_RUN=/home/openfoam/OpenFOAM/user-1.6-ext/run
  export FOAM_SOLVERS=/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/applications/solvers
  export FOAM_SRC=/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/src
  export FOAM_TUTORIALS=/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/tutorials
  export FOAM_USER_APPBIN=/home/openfoam/OpenFOAM/user-1.6-ext/applications/bin/linux64Gcc54DPOpt
  export FOAM_USER_LIBBIN=/home/openfoam/OpenFOAM/user-1.6-ext/lib/linux64Gcc54DPOpt
  export FOAM_UTILITIES=/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/applications/utilities
  export MPI_ARCH_PATH=/usr
  export WM_DIR=/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/wmake
  export WM_PROJECT_DIR=/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext
  export WM_PROJECT_INST_DIR=/home/openfoam/OpenFOAM
  export WM_PROJECT_USER_DIR=/home/openfoam/OpenFOAM/user-1.6-ext
  export WM_THIRD_PARTY_DIR=/home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/ThirdParty

%post
  chmod -R 777 /home/openfoam/OpenFOAM

I then rebuilt the image

sudo singularity build OpenFOAM-1.6-ext.simg Singularity

The permission issues were resolved, but then I encountered error messages related storage space issue

cp: error writing 'damBreakWithObstacle/0/polyMesh/faces': No space left on device
cp: error writing 'damBreakWithObstacle/0/polyMesh/neighbour': No space left on device
cp: error writing 'damBreakWithObstacle/0/polyMesh/owner': No space left on device

I read that the solution to that is to set the $SINGULARITY_CACHEDIR to a different location. What are some typical locations to set the cache directory?

Does the build fail when it’s extracting layers, or when it’s doing your customization? If the first, then it would be fairly easy to use /tmp for the cache. Try:

mkdir -p /tmp/.singularity
export SINGULARITY_CACHEDIR=/tmp/.singularity

I’m assuming you aren’t running on an HPC resource given that you have sudo, but if you were doing a build of just the docker container on HPC (sudo not required) you could export to somewhere like $SCRATCH:

mkdir -p $SCRATCH/.singularity
export SINGULARITY_CACHEDIR=$SCRATCH/.singularity

That’s actually been such a common recommendation that we have it done by default by our admins (and so you might ask your cluster admin to do the same!) I mention it because if you
are having trouble building locally, an option would be to do those additional customizations in the Docker container, push to something like ww382/openfoam:singularity and then pull directly onto the cluster, either of these would work:

$ singularity pull docker://ww382/openfoam:singularity
$ singularity build docker://ww382/openfoam:singularity

So in summary:

  1. Try exporting the cache directory to /tmp/.singularity, or a filesystem with lots of space
  2. If you don’t have enough on your local machine, do the changes in the Dockerfile, push to a different tag, and then pull directly.

I was able to build successfully. The error occurred when I tried test run a tutorial case.

I shell into the image:

singularity shell OpenFOAM-1.6-ext.simg 

Then I sourced OpenFOAM bashrc:

source /home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/etc/bashrc 

I “cd-ed” into a tutorial case and executed the Allrun script:

cd /home/openfoam/OpenFOAM/OpenFOAM-1.6-ext/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/ && \
./Allrun 

Then I received the following errors:

cp: error writing '0/0-orig/U': No space left on device
cp: error writing '0/0-orig/alpha1': No space left on device
cp: error writing '0/0-orig/alpha1.org': No space left on device
cp: error writing '0/0-orig/pd': No space left on device

This looks like it’s not about the container, but the cluster / node where you are running it. I’m not familiar with the tutorial, but I’d take a look at the Allrun and determine where it’s trying to write files (is it mounted on the host, or is it trying to write into a read only container?) and then assessing if you have space there.

Also, if you are exporting all of those paths in the build recipe via the environment, what is gained from sourcing the bashrc?

I haven’t had a chance to work this out on a HPC yet because the system is down. In the meantime, I’m trying to figure out all these on my local machine. Since I’m running ubuntu on a virtual machine, could it be that the VM is somehow confused about where the execution is really occurring?

That was a good point. I was exporting all of those paths in the build recipe because sourcing the bashrc within the container didn’t seem to set up the paths for me. I now removed all of those paths in the recipe, build the image again, and sourcing the bashrc within the container. It seems like it’s sourcing the bashrc script on my local directory rather than that within the container.