简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM