Ahdee
Ahdee

Reputation: 4949

How to run an Rscript with entrypoint when using docker?

I'm trying to run an Rscript through entrypoint but for some reason when I do this it fails to recognize the file. Here is an example.

docker run -it --rm  -v /N/Rfinal/:/tmp --entrypoint "Rscript /tmp/test.R" rocker/rstudio:latest
docker: Error response from daemon: OCI runtime create failed: container_linux.go:345: 
starting container process caused "exec: \"Rscript /tmp/test.R\": 
stat Rscript /tmp/test.R: no such file or directory": unknown.

The way I can get bash command is through entrypoint for this particular docker. Is there anything I can do? thanks.

Upvotes: 3

Views: 1151

Answers (1)

jkr
jkr

Reputation: 19310

The --entrypoint argument takes the name of the executable, like bash, Rscript, python, etc. The arguments to that executable would go after the docker image name.

docker run -it --rm  -v /N/Rfinal/:/tmp --entrypoint Rscript rocker/rstudio:latest /tmp/test.R

You would use the form to override the default entrypoint of the docker image. But the rocker docker image does not set an entrypoint, so the entrypoint is /bin/sh (found after tracing the base image to ubuntu:focal). Because the entrypoint is /bin/sh, you can simply use Rscript /tmp/test.R after the docker image.

docker run -it --rm  -v /N/Rfinal/:/tmp rocker/rstudio:latest Rscript /tmp/test.R

Upvotes: 2

Related Questions