Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bash script wrapper for generating a singularity image from a local Docker image
#!/bin/bash
# Based on https://github.com/sylabs/singularity/issues/1537
# Usage: bash docker2singularity.sh mydockerimg mysingularity.simg
set -ueo pipefail
IMG=$1
FILEOUT=$2
PORT=${3:-5000}
if [ -f $FILEOUT ]; then
echo "File $FILEOUT exists!"
exit 1
fi
docker run -d -p $PORT:5000 --restart=always --name "registry-$IMG" registry:2
# Push local docker container to it
docker tag $IMG localhost:$PORT/$IMG
docker push localhost:$PORT/$IMG
# Build singularity container
SINGULARITY_NOHTTPS=1 singularity build $FILEOUT docker://localhost:$PORT/$IMG
docker rm -f "registry-$IMG"
docker rmi localhost:$PORT/$IMG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.