skip to Main Content

I’m trying to build a docker container for a tool named DECoN (versin 2.0.0). To do so, I’m doing these steps:

  1. start FROM the latest bash image
  2. RUN the download of the tool’s source code and extract it
  3. set the WORKDIR to the tool’s ./Linux subdirectory
  4. RUN the existing setup.sh script that is found within the Linux subdirectory.
# syntax=docker/dockerfile:1

# start from a bash image 
FROM bash:latest

# download files 
RUN wget https://github.com/RahmanTeam/DECoN/archive/refs/tags/v2.0.0.tar.gz && 
    tar -xf v2.0.0.tar.gz

# go to directory 
WORKDIR DECoN-2.0.0/Linux

# run setup script 
RUN setup.sh

# check directory content 
RUN ls 

You can see the existence of the script with the last RUN ls. However, the script is not found and the docker build returns the following error:

docker build -t decon:2.0.0 .

...

/bin/sh: setup.sh: not found
The command '/bin/sh -c setup.sh' returned a non-zero code: 127

Do you have any idea what I’m doing wrong? I don’t understand why the script is not found. I have tried setup.sh, ./setup.sh, /DECoN-2.0.0/Linux/setup.sh, but nothing works.

EDIT #1: This is the content of the bash script:

#!/bin/bash

Rscript sessionInfo.R > setup.log 2>&1

2

Answers


    1. RUN ./setup.sh is the correct way to run a shell script in the current WORKDIR. You can only use RUN setup.sh if the script is on the path.

    2. ls -al will confirm if the file has r-x permissions for the appropriate users. otherwise you will need to RUN chmod +x setup.sh to ensure it can be executed.

    3. As you are using bash:latest is it unlikely that the script references a shell that is not present, but if the first line of the .sh file references a shell that’s not present, it will return an error. i.e. If its #!/bin/ash then ensure that ash is actually present.

    4. Again, as you are downloading and unzipping in the container, this is unlikely, but if the zip file has been processed on a windows computer, there may be CRLF line endings in the .sh file. As Linux only recognises LF this means it processes #!/bin/bash<CR><LF> as an instruction to execute the shell /bin/bash<CR> which does not exist. Download the file and check it in an editor (VSCode) that can tell you the ending style.

    Login or Signup to reply.
  1. To debug this kind of problems, run the base image and execute the commands of the Dockerfile by hand on the prompt:

    docker run -it --rm bash:latest
    wget https://github.com/RahmanTeam/DECoN/archive/refs/tags/v2.0.0.tar.gz
    tar -xf v2.0.0.tar.gz
    cd DECoN-2.0.0/Linux
    ./setup.sh
    

    The last line fails because, as you have noted, it runs Rscript which is not present in your (very minimal) base image. Rscript belongs to the R language so I have tried again with the official R base image:

    docker run -it --rm r-base:latest bash
    wget https://github.com/RahmanTeam/DECoN/archive/refs/tags/v2.0.0.tar.gz
    tar -xf v2.0.0.tar.gz
    cd DECoN-2.0.0/Linux
    ./setup.sh
    

    This time the script runs and creates the following setup.log:

    # Bootstrapping renv 0.15.4 --------------------------------------------------
    * Downloading renv 0.15.4 ... OK
    * Installing renv 0.15.4 ... Done!
    * Successfully installed and loaded renv 0.15.4.
    Error: package 'BiocManager' is not available
    In addition: Warning messages:
    1: This project is configured to use R version '4.2.0', but '4.3.1' is currently being used.
    2: could not retrieve available packages for url 'https://cran.ma.imperial.ac.uk/src/contrib'
    Traceback (most recent calls last):
    20: source("renv/activate.R")
    19: withVisible(eval(ei, envir))
    18: eval(ei, envir)
    17: eval(ei, envir)
    16: local(...)
    15: eval.parent(substitute(eval(quote(expr), envir)))
    14: eval(expr, p)
    13: eval(expr, p)
    12: eval(quote(...), new.env())
    11: eval(quote(...), new.env())
    10: renv::load()
     9: renv_load_bioconductor(project, lockfile$Bioconductor)
     8: renv_bioconductor_init()
     7: renv_bioconductor_init_biocmanager()
     6: install("BiocManager")
     5: retrieve(names(remotes))
     4: handler(package, renv_retrieve_impl(package))
     3: renv_retrieve_impl(package)
     2: stopf("package '%s' is not available", package)
     1: stop(sprintf(fmt, ...), call. = call.)
    Execution halted
    

    The warning about the wrong version of R can be avoided by using r-base:4.2.0 instead of r-base:latest (recommended to be safe) but the error message package 'BiocManager' is not available persists.

    The URL referenced in the log is still valid and BiocManager is a package that must be installed within R. Since I’m not an expert of R, I stop my analysis here hoping it helps.

    UPDATE: Searching in Docker Hub I found some ready-made images that reference RahmanTeam/DECoN in the Dockerfile:

    This one explictly installs BiocManager:

    Other images could exist.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search