Home > Enterprise >  Errors Installing singularity inside dockerfile
Errors Installing singularity inside dockerfile

Time:03-21

I am trying to run a nextflow pipeline which uses an older version of nextflow (21.04.3) and java version 8. Since I have to use this pipeline on a remote server, therefore I can only use singularity.

As this nextflow pipeline also uses singularity pull calls therefore I need the singularity installed inside the docker image as well. Then, I can convert this image docker image to a singularity image and then I can move it to the remote server.

I am trying to install singularity inside dockerfile but I am getting errors,

This is the dockerfile that I am using,

FROM python:3.8.9-slim 
LABEL authors="[email protected],[email protected]" \
  description="Docker image containing requirements for the nfcore tools"

# Do not pick up python packages from $HOME
ENV PYTHONNUSERSITE=1

# Update pip to latest version
RUN python -m pip install --upgrade pip

# Install dependencies
COPY requirements.txt requirements.txt
RUN python -m pip install -r requirements.txt

# Install Nextflow dependencies
RUN apt-get update \
  && apt-get upgrade -y \
  && apt-get install -y git \
  && apt-get install -y wget

# Create man dir required for Java installation 
# and install Java
RUN mkdir -p /usr/share/man/man1 \
  && apt-get install -y  openjdk-11-jre \
  && apt-get clean -y && rm -rf /var/lib/apt/lists/*

# Install Singularity 
RUN wget -O- http://neuro.debian.net/lists/xenial.us-ca.full | tee /etc/apt/sources.list.d/neurodebian.sources.list && \ apt-key adv --recv-keys --keyserver hkp://pool.sks-keyservers.net:80 0xA5D32F012649A5A9 && \ apt-get update 

RUN apt-get install -y singularity-container

# Setup ARG for NXF_VER ENV
ARG NXF_VER=""
ENV NXF_VER ${NXF_VER}
# Install Nextflow
RUN wget https://github.com/nextflow- io/nextflow/releases/download/v21.04.3/nextflow | bash \
  && mv nextflow /usr/local/bin \
  && chmod a rx /usr/local/bin/nextflow
# Add the nf-core source files to the image
COPY . /usr/src/nf_core
WORKDIR /usr/src/nf_core

# Install nf-core
RUN python -m pip install .

# Set up entrypoint and cmd for easy docker usage
CMD [ "." ]

These are the errors I am getting

Step 9/17 : RUN wget -O- http://neuro.debian.net/lists/xenial.us-ca.full | tee 
/etc/apt/sources.list.d/neurodebian.sources.list && \ apt-key adv --recv-keys -- 
keyserver hkp://pool.sks-keyservers.net:80 0xA5D32F012649A5A9 && \ apt-get update
---> Running in afc3dcbbd1ee
--2022-03-17 17:40:19--  http://neuro.debian.net/lists/xenial.us-ca.full
Resolving neuro.debian.net (neuro.debian.net)... 129.170.233.11
Connecting to neuro.debian.net (neuro.debian.net)|129.170.233.11|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 262
Saving to: ‘STDOUT’

 0K                                                       100% 18.4M=0s

deb http://neurodeb.pirsquared.org data main contrib non-free
#deb-src http://neurodeb.pirsquared.org data main contrib non-free
deb http://neurodeb.pirsquared.org xenial main contrib non-free
#deb-src http://neurodeb.pirsquared.org xenial main contrib non-free
2022-03-17 17:40:19 (18.4 MB/s) - written to stdout [262/262]

/bin/sh: 1:  apt-key: not found
The command '/bin/sh -c wget -O- http://neuro.debian.net/lists/xenial.us-ca.full | tee /etc/apt/sources.list.d/neurodebian.sources.list && \ apt-key adv --recv-keys --keyserver hkp://pool.sks-keyservers.net:80 0xA5D32F012649A5A9 && \ apt-get update' 
returned a non-zero code: 127

I there a way to install singularity using a dockerfile ?

Thanks

CodePudding user response:

I made some changes in the dockerfile based on the method to install singularity in linux given here.

The complete dockerfile with which I was able to run successfully nextflow, java and singularity within singularity is given below,

FROM python:3.8.9-slim 
LABEL 
authors="[email protected],[email protected]" \
  description="Docker image containing requirements for the nfcore tools"

# Do not pick up python packages from $HOME
ENV PYTHONNUSERSITE=1

# Update pip to latest version
RUN python -m pip install --upgrade pip

# Install dependencies
COPY requirements.txt requirements.txt
RUN python -m pip install -r requirements.txt

# Install Nextflow dependencies
RUN apt-get update \
  && apt-get upgrade -y \
  && apt-get install -y git \
  && apt-get install -y wget

# Create man dir required for Java installation 
# and install Java
RUN mkdir -p /usr/share/man/man1 \
  && apt-get install -y  openjdk-11-jre \
  && apt-get clean -y && rm -rf /var/lib/apt/lists/*


# Install Singularity

RUN apt-get update && apt-get install -y \
build-essential \
libssl-dev \
uuid-dev \
libgpgme11-dev \
squashfs-tools \
libseccomp-dev \
wget \
pkg-config \
procps

# Download Go source version 1.16.3, install them and modify the PATH
ENV VERSION=1.16.3 
ENV OS=linux 
ENV ARCH=amd64
RUN wget https://dl.google.com/go/go$VERSION.$OS-$ARCH.tar.gz && \
tar -C /usr/local -xzvf go$VERSION.$OS-$ARCH.tar.gz && \
rm go$VERSION.$OS-$ARCH.tar.gz && \
echo 'export PATH=$PATH:/usr/local/go/bin' | tee -a /etc/profile

# Download Singularity from version 3.7.3 (security version)
ENV VERSION=3.7.3
RUN wget https://github.com/sylabs/singularity/releases/download/v${VERSION}/singularity-${VERSION}.tar.gz && \
tar -xzf singularity-${VERSION}.tar.gz


# Compile Singularity sources and install it


RUN export PATH=$PATH:/usr/local/go/bin && \
cd singularity && \
./mconfig --without-suid && \
make -C ./builddir && \
make -C ./builddir install

# Setup ARG for NXF_VER ENV
ARG NXF_VER=""
ENV NXF_VER ${NXF_VER}
# Install Nextflow
RUN wget https://github.com/nextflow-io/nextflow/releases/download/v21.04.3/nextflow | bash \
  && mv nextflow /usr/local/bin \
  && chmod a rx /usr/local/bin/nextflow
# Add the nf-core source files to the image
COPY . /usr/src/nf_core
WORKDIR /usr/src/nf_core

# Install nf-core
RUN python -m pip install .

# Set up entrypoint and cmd for easy docker usage
CMD [ "." ]
  • Related