Carpetfizz
Carpetfizz

Reputation: 9169

Running a shell script that runs a python program, then an R program

I have a shell script that runs a Python program to pre-process some data and then runs an R program that does some long running task on it. I'm learning to use Docker and I've been running

FROM r-base:latest
FROM python
COPY . /usr/local/src/scripts
WORKDIR /usr/local/src/scripts
CMD ["./myscript.sh"]

To my understanding it does the following:

  1. Get R
  2. Get Python
  3. Copy my current directory to /usr/local/src/scripts
  4. Change directory to /usr/local/src/scripts
  5. Run ./myscript.sh

Inside myscript.sh I use the R CMD ... syntax for running my R script. However, when this docker image is run I get the following error:

./myscript.sh: line 8: R: command not found

This suggests that the script, when run inside the container, is not recognizing the R program. I can confirm that ./myscript.sh works locally but I cannot expose any proprietary code.

Upvotes: 1

Views: 218

Answers (1)

T. Arboreus
T. Arboreus

Reputation: 1059

The FROM command sets the base image that your Dockerfile builds on. You should only have one of these. After that, if you need additional tools that aren't in the base image, run commands that use platform-dependent package managers, such as

RUN apt-get update && apt-get install -y \
    package-foo \
    package-bar

This would be for a Debian-based image, such as Ubuntu.

Upvotes: 1

Related Questions