rocker-org / rocker

R configurations for Docker
https://rocker-project.org
GNU General Public License v2.0
1.45k stars 273 forks source link

Packages + data files removed on container update (UNRAID) #424

Closed Hokieboy01 closed 3 years ago

Hokieboy01 commented 3 years ago

This may just be my own incompetence, but any packages that I add via install.packages() are removed upon container update. I also lose any data files that I had stored in the default directory (.rmd, .csv, etc). As the title states, this is on UNRAID. Is there a way for me to keep my packages and files, or would I be better off delaying updates until I want to mess with backing stuff up and adding it back after the update?

eddelbuettel commented 3 years ago

Look into Docker tutorials and the -v and -w flags to have the container mount and access host directories and files, and persist there:

edd@rob:~$ mkdir mytmp                                            # local emtpy directory used across Docker runs
edd@rob:~$ docker run --rm -ti -v ~/mytmp:/mytmp -w /mytmp rocker/r-base install2.r -l /mytmp digest      
trying URL 'https://cloud.r-project.org/src/contrib/digest_0.6.25.tar.gz'    
Content type 'application/x-gzip' length 145642 bytes (142 KB)
==================================================
downloaded 142 KB                    

* installing *source* package ‘digest’ ...
[....]
* DONE (digest)

The downloaded source packages are in
        ‘/tmp/downloaded_packages’
edd@rob:~$ 

Now we have it in mytmp:

edd@rob:~$ ls -l mytmp/
total 4
drwxrwxr-x 11 root root 4096 Sep 28 15:45 digest
edd@rob:~$ 

And can use it again for the next Docker run:

edd@rob:~$ docker run --rm -ti -v ~/mytmp:/mytmp -w /mytmp rocker/r-base r -e 'library(digest, lib.loc="/mytmp"); cat("All good\n")'
All good
edd@rob:~$ 

No issue with our containers so I'll close this. Please free to report back if something on our end mishaves.