mbhall88 / rasusa

Randomly subsample sequencing reads or alignments
https://doi.org/10.21105/joss.03941
MIT License
211 stars 17 forks source link

Docker image issue #35

Closed genignored closed 2 years ago

genignored commented 2 years ago

it appears that there is an issue with the docker container. When I run the command set on the README, I get:

docker run quay.io/mbhall88/rasusa:joss_paper
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/bin/bash": stat /bin/bash: no such file or directory: unknown.
ERRO[0008] error waiting for container: context canceled
mbhall88 commented 2 years ago

Hi @genignored,

Thanks for pointing this out. It turns out bash is installed in a different location in the official bash container. This should be fixed now if you run docker run quay.io/mbhall88/rasusa:9bbd6a4 --help. It will also be released in version 0.6.1 once you confirm this works for you. Could you please close this issue when you confirm this has fixed your problem?

evanbiederstedt commented 2 years ago

Hi @mbhall88

Sorry to butt in, just trying this myself. FWIW, I get the following:

% docker run quay.io/mbhall88/rasusa:9bbd6a4 --help
error: The following required arguments were not provided:
    --bases <bases>
    --coverage <FLOAT>
    --genome-size <size|faidx>
    --input <input>...

USAGE:
    rasusa --bases <bases> --compress-level <1-9> --coverage <FLOAT> --genome-size <size|faidx> --input <input>...

For more information try --help

I guess I don't use these sorts of commands as it makes it difficult to run the container interactively with docker run -it: https://github.com/mbhall88/rasusa/blob/master/Dockerfile#L21

But that's your call of course :)

genignored commented 2 years ago

Sorry for the delay. Yes, it will at least download and run, but as Evan mentions above, it doesn't actually call the help statement.

mbhall88 commented 2 years ago

Hi both,

Thanks for the info. I think this is fixed now in ca421f5 (I have tested your command locally with the latest image @evanbiederstedt and it works as expected). Let me know if there are still problems.

docker run quay.io/mbhall88/rasusa:ca421f5 --help
evanbiederstedt commented 2 years ago

Hi @mbhall88

Yes, that works for me. I think you could close this ticket.

Personally, I like writing Docker images such that I can use them interactively e.g. docker run -it image /bin/bash and then I can use the command rasusa if I wish.

But that's your call :)

Thanks for the help and great tool!

mbhall88 commented 2 years ago

Excuse my ignorance (I never use docker to run containers - I use singularity) - but doesn't the exec command allow you to do that? https://docs.docker.com/engine/reference/commandline/exec/

evanbiederstedt commented 2 years ago

Hi @mbhall88

Sorry for hijacking this entire issue...

(I never use docker to run containers - I use singularity)

I'm pretty sure Singularity works the same way in this regard. They're essentially the same in terms of the API, and what they do.

All I am saying is the following:

Let's say I modify your Dockerfile slightly, like this:

FROM rust:1.54 AS builder

COPY . /rasusa

WORKDIR /rasusa

ARG TARGET="x86_64-unknown-linux-musl"

RUN apt update \
    && apt install -y musl-tools \
    && rustup target add "$TARGET" \
    && cargo build --release --target "$TARGET" \
    && strip target/${TARGET}/release/rasusa

The command docker run -it container will pull the image if it's not already downloaded, and you'll interactively use it.

docker run -it container_name /bin/bash

I'll find myself using the Linux OS from rust:1.54 as root. I can then interactively run rasusa however I want, and possibly mount local volumes to work with data, etc.

root@56700e6f1d3c:/rasusa# pwd
/rasusa
root@56700e6f1d3c:/rasusa# cd /rasusa/target/x86_64-unknown-linux-musl/release
root@56700e6f1d3c:/rasusa/target/x86_64-unknown-linux-musl/release# ls
build  deps  examples  incremental  rasusa  rasusa.d
root@56700e6f1d3c:/rasusa/target/x86_64-unknown-linux-musl/release# ./rasusa --help
rasusa 0.6.0
Randomly subsample reads to a specified coverage.

USAGE:
    rasusa [FLAGS] [OPTIONS] --bases <bases> --coverage <FLOAT> --genome-size <size|faidx> --input <input>...

FLAGS:
....

It's just how I normally use containers, fwiw. It provides the user more flexibility, e.g. to hook into Snakemake or Nextflow, or just do a quick analysis using the container.

The following might have good tips as well: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/

mbhall88 commented 2 years ago

Hey @evanbiederstedt ,

Thanks for the context.

Looking at https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#entrypoint it seems

The best use for ENTRYPOINT is to set the image’s main command, allowing that image to be run as though it was that command

In this case it would be rasusa.

I do see what you're saying though. This isn't an issue for singularity as you can use the shell command to do what you're trying to do with docker - i.e., get an interactive shell inside the container.

You can do this with docker by overriding the entrypoint

docker run -it --entrypoint bash quay.io/mbhall88/rasusa
evanbiederstedt commented 2 years ago

Hi @mbhall88

This is a very good point, and apologies for getting too opinionated here :)

You can do this with docker by overriding the entrypoint

I'd totally forgotten about this flag! (If I had ever learned it previously...) Thank you for showing me this! That's exceptionally useful.

I've gotten used to docker run -it image /bin/bash but the above makes far more sense.

Anyways, I think this issue is definitely solved now. Thank you, Michael!