Skip to content

Commit 2755d60

Browse files
committed
enable setting mount points via a command line argument
1 parent 4cfedff commit 2755d60

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,16 @@ You need to use the `docker info` command to check your docker version and use i
4949

5050
Currently only the 1.10, 1.11, 1.12, and 1.13 versions are supported. If you are using an older version of Docker you will need to upgrade.
5151

52+
### My cluster/HPC requires Singularity images to include specific mount points
53+
If you are getting `WARNING: Non existant bind point (directory) in container: '/shared_fs'` or a similar error when running your Singularity image that means that your Singularity images require custom mount points. To make the error go away you can specify the mount points required by your system when creating the Singularity image:
54+
55+
docker run \
56+
-v /var/run/docker.sock:/var/run/docker.sock \
57+
-v D:\host\path\where\to\ouptut\singularity\image:/output \
58+
--privileged -t --rm \
59+
singularityware/docker2singularity \
60+
-m "/shared_fs /custom_mountpoint2" \
61+
ubuntu:14.04
62+
5263
## Acknowledgements
5364
This work is heavily based on the `docker2singularity` work done by [vsoch](https://github.com/vsoch) and [gmkurtzer](https://github.com/gmkurtzer). Hopefully most of the conversion code will be merged into Singularity in the future making this container even leaner!

docker2singularity.sh

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,34 @@
1313
set -o errexit
1414
set -o nounset
1515

16-
if [ -z $1 ]; then
17-
echo "no Docker image specified!";
16+
USAGE="Usage: docker2singularity [-m \"/mount_point1 /mount_point2\"] docker_image_name"
17+
18+
# --- Option processing --------------------------------------------
19+
if [ $# == 0 ] ; then
20+
echo $USAGE
1821
exit 1;
19-
else
20-
image=$1
2122
fi
22-
23+
mount_points="/oasis /projects /scratch /local-scratch /work /home1 /corral-repl /beegfs /share/PI /extra"
24+
while getopts ':hm:' option; do
25+
case "$option" in
26+
h) echo "$USAGE"
27+
exit
28+
;;
29+
m) mount_points=$OPTARG
30+
;;
31+
:) printf "missing argument for -%s\n" "$OPTARG" >&2
32+
echo "$usage" >&2
33+
exit 1
34+
;;
35+
\?) printf "illegal option: -%s\n" "$OPTARG" >&2
36+
echo "$usage" >&2
37+
exit 1
38+
;;
39+
esac
40+
done
41+
shift $((OPTIND - 1))
42+
43+
image=$1
2344

2445
################################################################################
2546
### CONTAINER RUNNING ID #######################################################
@@ -144,7 +165,7 @@ rm -rf $TMPDIR
144165
### Permissions ################################################################
145166
################################################################################
146167
echo "(6/9) Adding mount points..."
147-
singularity exec --writable --contain $new_container_name /bin/sh -c "mkdir -p /oasis /projects /scratch /local-scratch /work /home1 /corral-repl /beegfs /share/PI /extra"
168+
singularity exec --writable --contain $new_container_name /bin/sh -c "mkdir -p ${mount_points}"
148169

149170
# making sure that any user can read and execute everything in the container
150171
echo "(7/9) Fixing permissions..."

0 commit comments

Comments
 (0)