The examples for a book on high performance computing run via Docker running a Dockerfile:
docker run -it --entrypoint /bin/bash chapter5
This puts the user into a Docker container where various subdirectories are populated with code examples that can be run from within the container. The problem is that most HPC clusters do not run Docker; they run Singularity/Apptainer.
One approach to run this under Singularity is to build a Singularity container from the Dockerfile, load that to DockerHub, then 'exec' that image. That starts a container for the user, but the subdirectories are not populated, so the user has no code examples to run.
My best guess is that Singularity requires the flags "-it --entrypoint /bin/bash", but Singularity does not have these same flags and I cannot find any substitutes.
How can a Dockerfile be run by Singularity with equivalent "Docker flags"?
This docker container clones the git repo into the container itself, and the code is built and run there. That is problematic for apptainer/singularity, since the container is read only, and also unnecessary, since apptainer makes it easy to map in host files at run time. Instead, use the repo on the host by mapping it into the container using the -B flag.
First, after building and pushing the docker image to dockerhub as usual, build the apptainer image from the docker image by doing: apptainer build chapter5.sif docker://me/chapter5:latest
Assuming I had cloned Chapter5 into /home/me/Chapter5 on the host machine, I can launch the apptainer container like this:
apptainer exec -B /home/me/Chapter5:/apps/Chapter5 chapter5.sif /bin/bash
That will launch a shell in the container. I can then cd to /apps/Chapter5 and do the cmake, make, etc.
I hope that helps.