Skip to content

Commit f5ae6b3

Browse files
committed
adding extra options argument
Signed-off-by: Vanessa Sochat <vsochat@stanford.edu>
1 parent 5ef7d65 commit f5ae6b3

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ USAGE: docker2singularity [-m "/mount_point1 /mount_point2"] [options] docker_im
2020
OPTIONS:
2121

2222
Image Format
23-
-f: build development sandbox (folder)
24-
-w: non-production writable image (ext3)
25-
26-
Default is squashfs (recommended)
27-
23+
--folder -f build development sandbox (folder)
24+
--option -o add a custom option to build (-o --fakeroot or -option 'section post' )
25+
--writable -w non-production writable image (ext3)
26+
Default is squashfs (recommended) (deprecated)
27+
--name -n provide basename for the container (default based on URI)
28+
--mount -m provide list of custom mount points (in quotes!)
29+
--help -h show this help and exit
2830
```
2931

3032
### Options
@@ -41,6 +43,17 @@ Note that you are able to convert easily from a folder or ext3 image using Singu
4143

4244
- `-m` specify one or more mount points to create in the image.
4345

46+
**Options**
47+
48+
If you look at `singularity build --help` there are a variety of options available.
49+
You can specify some custom option to the command using the `--option` flag. Make sure
50+
that each option that you specify is captured as a single string. E.g.,:
51+
52+
```bash
53+
--option --fakeroot
54+
--option '--section post'
55+
```
56+
4457
**Image Name**
4558

4659
The last argument (without a letter) is the name of the docker image, as you would specify to run with Docker (e.g., `docker run ubuntu:latest`)

docker2singularity.sh

100644100755
Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ function usage() {
4444
4545
Image Format
4646
--folder -f build development sandbox (folder)
47+
--option -o add a custom option to build (-o --fakeroot or -option 'section post' )
4748
--writable -w non-production writable image (ext3)
48-
Default is squashfs (recommended)
49+
Default is squashfs (recommended) (deprecated)
4950
--name -n provide basename for the container (default based on URI)
5051
--mount -m provide list of custom mount points (in quotes!)
5152
--help -h show this help and exit
@@ -61,6 +62,7 @@ fi
6162
mount_points="/oasis /projects /scratch /local-scratch /work /home1 /corral-repl /corral-tacc /beegfs /share/PI /extra /data /oak"
6263
image_format="squashfs"
6364
new_container_name=""
65+
options=""
6466

6567
while true; do
6668
case ${1:-} in
@@ -78,6 +80,11 @@ while true; do
7880
mount_points="${1:-}"
7981
shift
8082
;;
83+
-o|--option)
84+
shift
85+
options="${1:-} ${options}"
86+
shift
87+
;;
8188
-f|--folder)
8289
shift
8390
image_format="sandbox"
@@ -107,6 +114,7 @@ done
107114

108115
image=${1}
109116

117+
exit 0
110118
echo ""
111119
echo "Image Format: ${image_format}"
112120
echo "Docker Image: ${image}"
@@ -311,11 +319,11 @@ docker rm $container_id >> /dev/null
311319
# Build a final image from the sandbox
312320
echo "(9/10) Building ${image_format} container..."
313321
if [ "$image_format" == "squashfs" ]; then
314-
new_container_name=${new_container_name}.simg
315-
singularity build ${new_container_name} $build_sandbox
322+
new_container_name=${new_container_name}.sif
323+
singularity build ${options} ${new_container_name} $build_sandbox
316324
elif [ "$image_format" == "writable" ]; then
317-
new_container_name=${new_container_name}.img
318-
singularity build --writable ${new_container_name} $build_sandbox
325+
new_container_name=${new_container_name}.simg
326+
singularity build ${options} --writable ${new_container_name} $build_sandbox
319327
else
320328
mv $build_sandbox $new_container_name
321329
fi

0 commit comments

Comments
 (0)