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:
- start
FROM
the latest bash image RUN
the download of the tool’s source code and extract it- set the
WORKDIR
to the tool’s./Linux
subdirectory RUN
the existingsetup.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
RUN ./setup.sh
is the correct way to run a shell script in the current WORKDIR. You can only useRUN setup.sh
if the script is on the path.ls -al
will confirm if the file has r-x permissions for the appropriate users. otherwise you will need toRUN chmod +x setup.sh
to ensure it can be executed.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 thatash
is actually present.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.To debug this kind of problems, run the base image and execute the commands of the
Dockerfile
by hand on the prompt: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:This time the script runs and creates the following
setup.log
:The warning about the wrong version of R can be avoided by using
r-base:4.2.0
instead ofr-base:latest
(recommended to be safe) but the error messagepackage '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 theDockerfile
:This one explictly installs
BiocManager
:Other images could exist.