SBIMB / StellarPGx

Calling star alleles in highly polymorphic pharmacogenes (e.g. CYP450 genes) by leveraging genome graph-based variant detection.
MIT License
29 stars 6 forks source link

Question: Running StellarPGx within Docker #15

Closed ajpar94 closed 7 months ago

ajpar94 commented 2 years ago

Hello,

I am trying to run StellarPgx together with Docker (not Singularity) from within a Docker container. The whole "Docker in Docker" situation is still a bit confusing to me. However, what I have tried is to define a docker image with docker and nextflow installed using this Dockerfile:

FROM ubuntu

RUN apt update -y
RUN apt install -y docker.io python3 curl default-jre

WORKDIR /home

# install Nextflow
RUN curl -fsSL get.nextflow.io | bash
RUN mv nextflow /bin

RUN git clone https://github.com/SBIMB/StellarPGx.git

# copy resources and enable Docker in config
COPY . .
COPY resources/nextflow.config ./StellarPGx/nextflow.config

After building the image, I run the following commands:

and from within the docker container, I do:

I get the following error:

Error executing process > 'call_sv_del (1)'

Caused by:
  Process `call_sv_del (1)` terminated with an error exit status (1)

Command executed:

  graphtyper genotype_sv hg38/chr22_hg38.fasta --sam=SIM001.bam --region=chr22:42126000-42137500 --output=SIM001_sv_del cyp_hg38/sv_test.vcf.gz

Command exit status:
  1

Command output:
  (empty)

Command error:
  /bin/bash: .command.sh: No such file or directory

Work dir:
  /home/StellarPGx/work/6e/9688c4f8f10e18033aef82713c0ce5

Tip: view the complete command output by changing to the process work dir and entering the command `cat .command.out`

Is there a way to resolve this issue? Is there another way to do it (avoiding Docker in Docker)?

twesigomwedavid commented 2 years ago

Hi @ajpar94,

Thanks for raising this.

I think it would be much easier to run StellarPGx with Docker vs within Docker. You don't need to be inside any container. Simply provide the following in the nextflow.config file:

  1. Docker container (see recommended container on line 70 in the nextflow.config file -- under the process stanza), i.e. uncomment the line
  2. Enable Docker (see Docker stanza in the nextflow.config file)
  3. Disable Singularity (see Singularity stanza in the nextflow.config file) and comment out the path to the Singularity container

Afterwards, you can run StellarPGx on your normal command line. Be sure to check that the Docker daemon is running.

ajpar94 commented 2 years ago

Running StellarPGx with Docker works perfectly fine. However, I would like to run it as part of a kubernetes cluster and therefore it would be ideal to have it all in one docker container.

twesigomwedavid commented 2 years ago

@ajpar94,

Thanks. If you try to run Nextflow from inside a Docker container, your paths and directories are not what you normally see. Therefore, the easiest way is to run StellarPGx with Docker.

Unfortunately, we don't have a Kubernetes cluster that we can test any changes that would need to be made for your particular use case.

twesigomwedavid commented 2 years ago

@ajpar94, Could you try merging the component tools of our Docker container with your existing container or Dockerfile? In this way, you'll only be dealing with one Dockerfile. Be sure to update the path in your nextflow.config to point to the merged container.

Since you've already pulled the StellarPGx container, you can add the following to your Dockerfile:

WORKDIR /
COPY --from=twesigomwedavid/stellarpgx-dev /usr/local/bin/tabix /usr/local/bin/
COPY --from=twesigomwedavid/stellarpgx-dev /usr/local/bin/bgzip /usr/local/bin/
COPY --from=twesigomwedavid/stellarpgx-dev /usr/local/bin/bcftools /usr/local/bin/
COPY --from=twesigomwedavid/stellarpgx-dev /usr/local/bin/samtools /usr/local/bin/
COPY --from=twesigomwedavid/stellarpgx-dev /usr/local/bin/graphtyper /usr/local/bin/graphtyper 

I see you already have Python3 in one of your lines.

ajpar94 commented 2 years ago

Sorry for getting back to you so late. I had some other stuff to do. I tried out your suggestion and this time I get a slightly different error:

Error executing process > 'get_depth (1)'

Caused by:
  Process `get_depth (1)` terminated with an error exit status (1)

Command executed:

  samtools bedcov --reference hg38/chr22_hg38.fasta cyp_hg38/test3.bed SIM001.bam > SIM001_cyp2d6_ctrl.depth

Command exit status:
  1

Command output:
  (empty)

Command error:
  /bin/bash: .command.sh: No such file or directory

Work dir:
  /home/StellarPGx/work/98/bd5ddb097511ff01f994cea826cd9d

Tip: you can try to figure out what's wrong by changing to the process work dir and showing the script file named `.command.sh`

I checked: hg38/chr22_hg38.fasta and cyp_hg38/test3.bed are both there ...

twesigomwedavid commented 2 years ago

@ajpar94,

According to your error message, the file which is missing is .command.sh which Nextflow uses in its operation. Perhaps check to see if it is indeed in the work directory (/home/StellarPGx/work/98/bd5ddb097511ff01f994cea826cd9d).

As I mentioned, we don't have the option of testing on Kubernetes on our side at present. Perhaps some information here would help https://www.nextflow.io/docs/latest/kubernetes.html.

ajpar94 commented 2 years ago

Oh, you are right. But .command.sh does exist as well.

I will read about running nextflow with Kubernetes. If we find a working solution, I will let you know. Thank you for your help!

twesigomwedavid commented 2 years ago

Hi @ajpar94,

We went through some options you could try for your use case. The error you're getting seems to come from the fact that your /home/StellarPGx/ directory is not being mounted into the main docker image.

You mentioned that you're starting up the image as follows: docker run -v /var/run/docker.sock:/var/run/docker.sock -itd <image_name>

However, the correct command should probably be the following: docker run -v /var/run/docker.sock:/var/run/docker.sock -v /home/StellarPGx:/home/StellarPGx -it <image_name>

If this doesn't work, could you share the contents of your nextflow.config file? That would give us more context to help with debugging.

Thanks

twesigomwedavid commented 7 months ago

Closing this as there are no recent updates on the suggested solution.