CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Installation

[OpenFOAM.com] IcoFoam not found in docker when executed from outside

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By olesen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 14, 2021, 10:29
Default IcoFoam not found in docker when executed from outside
  #1
Member
 
Sunag R A
Join Date: Jul 2019
Location: Bangalore, India
Posts: 82
Rep Power: 7
sunagra27 is on a distinguished road
Dear all,


I wanted to run OpenFOAM simulation inside docker container, for this I have built the docker image from dockerfile. The dockerfile has Openfoam 5 installation along with necessary requirements.


1. When the image is built, OpenFOAM works perfectly when I enter into the container and test with "icoFoam" command.


2. But, when I exec it with "CMD" inside dockerfile, it throws an error stating "icoFoam not found".


3. All installation done with new user and not in root.


Below is the dockerfile content.


Code:
###################################################################################

   

USER root

# Install OpenFOAM5.0, paraviewopenfoam54 and PyFoam
 # Add dl.openfoam.org to the list of software repositories


 RUN sh -c "wget -O - http://dl.openfoam.org/gpg.key | apt-key add -"


 # Install the dependancies (Can also have a requirements file and build from there)


 RUN apt-get install software-properties-common -y
RUN add-apt-repository http://dl.openfoam.org/ubuntu
RUN apt-get install apt-transport-https -y
 
RUN apt-get update -y
 
RUN apt-get -y install openfoam5


# New user creation
RUN groupadd -r sunag && useradd -m -r -g sunag sunag

# Source bashrc
RUN echo "source /opt/openfoam5/etc/bashrc" >> /home/sunag/.bashrc

USER sunag

# Install pip packages for specific user
RUN python -m pip install --user numpy scipy pandas scikit-image opencv-python PyFoam open3d numpy-stl gunicorn


WORKDIR /home
CMD icoFoam
4. The CMD command when docker image is run, throws "icoFoam not found", but when the entering the container and running icoFoam, it works perfectly.


So, what am I missing here or what work around needs to be done?


Hope, it is understood.


Regards,
Sunag R A.
sunagra27 is offline   Reply With Quote

Old   October 15, 2021, 16:22
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
If you are running CMD, I don't know that you will have all scripts setup properly. For this we use a backend dispatch script to relay things through. See the packaging files.

https://develop.openfoam.com/packaging/containers

For example, if you even just grab the start script as described here: https://develop.openfoam.com/Develop...ompiled/docker

And use the 'openfoam-docker' script.
For example,
Code:
$ openfoam-docker / icoFoam -help
With this script and container, you can do lots of different things:
  • openfoam-docker -help # help for the script
  • openfoam-docker # start interactive (shell) session with openfoam
  • openfoam-docker / icoFoam # Run a command within the container
  • openfoam-docker -c -- comand args # Run some shell commands
  • openfoam-docker / help # Display README from within the container
  • openfoam-docker / -help # Display help for the dispatch script within the container
  • openfoam-docker / -verbose icoFoam # Verbose sourcing of openfoam, execute application
I think that your problem has been solved if you either just use one of these existing container workflows, or you adapt the container (or scripts) to better suit your purposes. However, either you need to create dedicated containers for each solver, utility. Or you need to use a myriad of symlinks within the container to define different dispatching. But since you will very likely want to have script such as 'openfoam-docker', would probably be to do all of your symlink wrapping there.


EDIT: forgot the mention there is also a 'openfoam-docker -podman' option if that is your preference.
olesen is offline   Reply With Quote

Old   October 19, 2021, 12:37
Default
  #3
Member
 
Sunag R A
Join Date: Jul 2019
Location: Bangalore, India
Posts: 82
Rep Power: 7
sunagra27 is on a distinguished road
Dear oselen,


Thank you for your reply. With respect to the links you have shared, I actually wanted openfoam v5 only since all the files are created according to that.



And, as per the dockerfile contents, all the installation is perfect since openfoam works inside the container without any issues.

Is there any work around other than the ones you have mentioned? Like, since the error says
Code:
/bin/sh/:1:icoFoam not found
, I checked with permission issues using chmod 777 and also changing ownership too. But, from docker CMD nothing seems to be working.


I do not want to enter the container and run the OpenFOAM simulations, since I will using flask code to get requests from outside the docker, where the flask code has a function of another python file which contains all the OpenFOAM related python codes for simulation. So, I need it to work from CMD only.


Regards,


Sunag R A.

Last edited by sunagra27; October 19, 2021 at 14:05.
sunagra27 is offline   Reply With Quote

Old   October 19, 2021, 19:33
Default
  #4
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by sunagra27 View Post
Dear oselen,

Thank you for your reply. With respect to the links you have shared, I actually wanted openfoam v5 only since all the files are created according to that.

And, as per the dockerfile contents, all the installation is perfect since openfoam works inside the container without any issues.

Is there any work around other than the ones you have mentioned? ...

I can only offer help on the openfoam.com docker installation. The "v5" you mention is from somebody else. If using CMD instead of ENTRYPOINT is what you require for you application (although I honestly don't see what was wrong with my solution) you'll have to do that on your own. However, in the end you will likely discover that you need a similar mechanism to get your environment setup (within the container) as part of your dispatch.
olesen is offline   Reply With Quote

Old   October 19, 2021, 19:36
Default
  #5
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by sunagra27 View Post
I do not want to enter the container and run the OpenFOAM simulations, since I will using flask code to get requests from outside the docker,...

I'm not sure if you noticed that the docker solution that I mentioned can be used non-interactively. Did it not work for you?
olesen is offline   Reply With Quote

Old   October 20, 2021, 07:08
Default
  #6
Member
 
Sunag R A
Join Date: Jul 2019
Location: Bangalore, India
Posts: 82
Rep Power: 7
sunagra27 is on a distinguished road
Dear oselen,


There is nothing wrong in your solution. I wanted to work with Openfoam v5 and so dint give a work around with the other versions.


I did solve it lately by adding all the ENV path to dockerfile which corresponds to Openfoam and now it is running perfectly.


Excrept of dockerfile ENV addition


Code:
ENV WM_PROJECT_INST_DIR /opt
ENV FOAM_RUN /home/niramai/OpenFOAM/-5.0/run
ENV ParaView_MAJOR 5.4
ENV WM_THIRD_PARTY_DIR /opt/ThirdParty-5.0
ENV WM_LDFLAGS -m64
ENV FOAM_APP /opt/openfoam5/applications
ENV WM_CXXFLAGS -m64 -fPIC -std=c++0x
ENV FOAM_UTILITIES /opt/openfoam5/applications/utilities
ENV FOAM_APPBIN /opt/openfoam5/platforms/linux64GccDPInt32Opt/bin
ENV ParaView_DIR /opt/paraviewopenfoam54
ENV WM_PRECISION_OPTION DP
ENV FOAM_SOLVERS /opt/openfoam5/applications/solvers
ENV FOAM_EXT_LIBBIN /opt/ThirdParty-5.0/platforms/linux64GccDPInt32/lib
ENV WM_CC gcc
ENV FOAM_USER_APPBIN /home/niramai/OpenFOAM/-5.0/platforms/linux64GccDPInt32Opt/bin

Likewise, all the ENV were added.


Regards,
Sunag R A.

Last edited by sunagra27; October 20, 2021 at 11:48.
sunagra27 is offline   Reply With Quote

Old   October 20, 2021, 15:58
Default
  #7
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
If you are defining the ENV yourself, you don't need most of those. Need WM_PROJECT_DIR so that OpenFOAM can find its etc/ content (eg, controlDict cellModels). Make sure that the value of FOAM_APPBIN is in the PATH and the value of FOAM_LIBBIN is in the LD_LIBRARY_PATH and that should be enough.
sunagra27 likes this.
olesen is offline   Reply With Quote

Reply

Tags
cmd, docker, openfoam


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[RapidCFD] Discussion thread on how to install and use RapidCFD newoscar OpenFOAM Community Contributions 88 May 17, 2024 10:39
error in fireFoam, when running the case wallFireSpread2D zhoubiao1088 OpenFOAM Running, Solving & CFD 9 February 1, 2018 19:45
[Other] Compiling hacFoam (Ubuntu 10.04)(OF2.0.0)(LAMMPS13Jul2010)) Henrik_E OpenFOAM Installation 3 September 29, 2016 17:16
OpenFOAM 1.7.1 installation problem on OpenSUSE 11.3 flakid OpenFOAM Installation 16 December 28, 2010 09:48
critical error during installation of openfoam Fabio88 OpenFOAM Installation 21 June 2, 2010 04:01


All times are GMT -4. The time now is 16:13.