0

I am writing a Docker container with R. For the dockerfile composition, I use VScode and its extension. At the moment I can run the container exactly as I wanted it, however, when I push the dockerfile to Github and from there triggers a build in dockerhub, I notice the following problem:

Dockerfile:

FROM nvidia/cuda:11.2.2-base-ubuntu20.04

# Install dependencies
RUN apt-get update && apt-get install -y \
    curl \
    ca-certificates \
    dumb-init \
    htop \
    sudo \
    gcc \
    bzip2 \
    libx11-6 \
    locales \
    man \
    git \
    procps \
    openssh-client \
    lsb-release \
  && rm -rf /var/lib/apt/lists/*

COPY installers /installers
COPY entrypoint.sh /usr/bin/entrypoint.sh

RUN /installers/install_R.sh

COPY run_simple.sh /usr/run_simple.sh

CMD ["bash","/usr/run_simple.sh"]

The error:

...
...
[91m/bin/sh: 1: /installers/install_R.sh: Permission denied
[0m
Removing intermediate container 1ea9ba9d9d2b
The command '/bin/sh -c /installers/install_R.sh' returned a non-zero code: 126

Apparently, the builder cannot access the copied files. So, if I run the file as RUN chmod +x /installers/install_R.sh, then, there is no installing problem. However, when I launch the container, then I cannot see anywhere R as if it would not be installed. That made me think it could have been installed for another user? or for a user that is not the same as the one running the container? or maybe is not installed at all?

If you could help me solving this issue, it would be highly appreciated.

Santi
  • 368
  • 2
  • 15
  • How are you launching the container? If you run `chmod` as you describe, how do you verify that things are installed as you expect? How does your application use `sudo`, `htop`, or `man` (or can you safely remove these packages from your image)? – David Maze Apr 03 '21 at 14:00
  • 1- I don´t fully "verify" that things get installed when I used `chmod`. I just know that the image build works with the dockerfile with the `chmod` command present. If I run an interactive session, I cannot find the bin with `whereis xxx`. 2- When I build the image, I took few parts from https://github.com/rocker-org/rocker-versioned2/tree/master/dockerfiles. I cannot tell which are totally required but most of them were already present in the template. – Santi Apr 03 '21 at 19:39

1 Answers1

0

The reason could be when the file was initially committed to Github it was not with execute permission. So when you test it locally the execute permission being there it works, but on a new clone it won't work

For that you need to use below

Updating and committing only a file's permissions using git version control

Also a better way would be to use below type of RUN statements

RUN sh /installers/install_R.sh

or

RUN chmod +x /installers/install_R.sh && /installers/install_R.sh
Tarun Lalwani
  • 142,312
  • 9
  • 204
  • 265
  • I might be doing something wrong because I tried that but it doesn't change anything. My git/.config file looks like: `[core] repositoryformatversion = 0 filemode = true` Still, if I push the image to dockerhub pre-build it works, but when I push the dockerfile to github and compose in dockerhub. – Santi Apr 04 '21 at 18:51