I am trying to create a custom Rocker based Docker image using a Dockerfile. In Dockerfile, I pull my own R package from the GitLab user server using:
RUN R -e "devtools::install_git('[custom gitlab server]', quiet = FALSE)"
Everything works fine, but I noticed that when the GitLab server is not working, or there is not enough RAM on the machine running Docker, the package does not install correctly and returns an error message in the R console. This behavior should be expected. However, Docker does not notice the error caused by R and continues to evaluate the rest of the Docker file. I would like Docker to not be able to create an image when this happens. That way, I could eventually prevent Kubernet from automatically deploying the incomplete Docker container.
So far I have been thinking about two possible solutions, but I am struggling with implementation:
- Level R : Wrap
tryCatch()around devtools::install_gitto catch a bug. But then what? To use stop? Will this lead to the fact that the docker construction process will stop? Can I use it withCallingHandlers()? - Level Dockerfile . Use shell command to check for errors? I can’t find the content
R --help, because at the moment I don’t have a Linux machine. Therefore, I’m not sure what R -e(execution I assume) actually is and what other commands can be passed along with R.
It seems that a similar problem is being discussed here and here , but I do not understand how they solved it.
, , Docker Kubernetes ?