Dockerfile Best practices?

Discussion about building and installing Elmer
Post Reply
andrewdnolan
Posts: 16
Joined: 26 Oct 2020, 18:33
Antispam: Yes

Dockerfile Best practices?

Post by andrewdnolan »

Hi all,

I have some question about best practices getting Elmer, specifically Elmer/Ice, up and running through Docker. I've used the Docker file linked in the github README (https://hub.docker.com/r/nwrichmond/elmerice/), which closely resembles the Dockerfile included in the "elmerfem" github repo under the "docker" folder https://github.com/ElmerCSC/elmerfem/bl ... dockerfile. While I've been able to run these Docker containers successful and have access to Elmer executables (e.g. elmerf90), some functionality is missing. Primarily the Dockerfile deletes the entire "elmerice" directory (not just the build directory, as in the compilation instructions). For example running

Code: Select all

$ find / -type d -name "elmerice" -print
returns nothing. So, while executables (e.g. elmerf90) work fine, all the files within "UserFunctions", "Meshers", "examples", etc... are gone.

As an immediate stopgap, I've commented out the line that deletes the "elmerice" directory ("rm -R /home/elmerice"). This works fine, but inorder to run/use any of the files withing the "elmerice" directory it requires "sudo" privileges. For example, to test the install you have to run

Code: Select all

sudo ctest -L elmerice-fast
otherwise these Cmake errors are rasied:

Code: Select all

CMake Error: Cannot open file for write: /home/elmerice/builddir/Testing/Temporary/LastTestsFailed.log.tmp
CMake Error: : System Error: Permission denied
Problem opening file: /home/elmerice/builddir/Testing/Temporary/LastTestsFailed.log
Cannot create log file: LastTestsFailed.log
if you run the test not in sudo mode.

I assume this has to do with the fact the user account (glacier) is created after the Elmer/Ice install, which is in the "/home" directory not "/home/glacier". I am currently trying to amend the Dockerfile to create the user first, then install Elmer/Ice within "/home/glacier" to circumvent the sys administrative hurdles.

I'm fairly new to docker and wondering if anyone has suggestions about how best to navigate these problems? For convenience I've attached the Dockerfile (with "rm -R /home/elmerice" commented out) that I describe above. Any help would be greatly appreciated.

Best,
Andrew
Attachments
Dockerfile.tar.gz
tarred Dockerfile since the normal extensionless version is not an accepted file type.
(3.5 KiB) Downloaded 181 times
andrewdnolan
Posts: 16
Joined: 26 Oct 2020, 18:33
Antispam: Yes

Re: Dockerfile Best practices?

Post by andrewdnolan »

Well I've successfully amended the Dockerfile in the "elmerfem" github repo under the "docker" folder (https://github.com/ElmerCSC/elmerfem/bl ... dockerfile). My amended Dockerfile can be found here: https://hub.docker.com/r/andrewdnolan/elmerice. My Dockerfile is pretty much the same as the one in the github repo, but with a reordering and omission of a couple of steps.

Primarily, the user account "glacier" is created before the elmer install, in order to overcome sys admin troubles outlined above. Then, the line in the original Dockerfile where the entire elmer directory is deleted has been commented out. I've decided to keep the "builddir" as well so that install can be tested. For the latest build of the Dockerfile, 27/29 of the Elmer/Ice (fast) compilation test pass.

With being fairly new to Docker I'm entirely sure about best practices. But my amended Dockerfile appears to be working, which is most important for me. If anyone had suggestions as how to better optimize this, they would be much appreciated. Feel free to submit a pull request here: https://github.com/andrewdnolan/docker-elmerice.

Hope that people find this amended Dockerfile useful!

Best,
Andrew
Post Reply