I'm trying to run a small test to learn how to install packages that reside within our private Bitbucket repos, and use them inside of a Docker container.
However, I'm running into an error where it seems like my package is being installed properly but then I can't load it inside the container.
My Dockerfile is as follows:
FROM rocker/r-ver:4.2.1
RUN mkdir /home/analysis
ENV BITBUCKET_USER 'me'
ENV BITBUCKET_PASSWORD 'mypassword'
RUN R -e "install.packages('remotes'); \
remotes::install_bitbucket(repo = '{org}/afp.data')"
COPY /scripts/my_script_2.R /home/analysis/my_script.R
CMD cd /home/analysis \
&& R -e "source('my_script.R')"
My script my_script.R
is as follows:
library(afp.data)
cat("hello world")
The output from my build process is as follows:
$ docker build -t test .
[+] Building 260.3s (9/9) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 494B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/rocker/r-ver:4.2.1 2.2s
=> [1/4] FROM docker.io/rocker/r-ver:4.2.1@sha256:84dbe29c3218221af453eca9bf95249d605920d9aa03598fcc96767242b7ea5e 0.0s
=> [internal] load build context 0.1s
=> => transferring context: 339B 0.0s
=> CACHED [2/4] RUN mkdir /home/analysis 0.0s
=> [3/4] RUN R -e "install.packages('remotes'); remotes::install_bitbucket(repo = '{repo}/afp.data')" 254.7s
=> [4/4] COPY /scripts/my_script_2.R /home/analysis/my_script.R 0.1s
=> exporting to image 3.2s
=> => exporting layers 3.2s
=> => writing image sha256:3d97fc19351b518bb1fd4a0ac23d4825a052297156f6e759ad5c64135c07a451 0.0s
=> => naming to docker.io/library/test 0.0s
It didn't seem like there were any errors. However when I run it with docker run test
I get the following:
$ docker run test
R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> source('my_script.R')
Error in library(afp.data) : there is no package called ‘afp.data’
Calls: source -> withVisible -> eval -> eval -> library
Execution halted
If it seems like afp.data
installed without errors, why can't I load it?
Any help on troubleshooting this will be appreciated. If I can provide more information please let me know how I can do so - very new to Docker!!