Using embedr With Docker

This is a description of how I use embedr inside Docker on Linux. I have a directory called "docker" that I use to hold an R file that I want to run, titled "program.R".

mkdir ~/docker
cd ~/docker

I place a copy of this Dockerfile into that directory. I build it with the command

docker build -t myr .

That creates a new Docker image by the name of "myr". It can then be built

docker run -v /home/lance/docker:/code myr

The -v option allows me to mount the docker directory as "/code" inside the Docker image. If I didn't care about saving the results (which would be weird, but whatever floats your boat) I could just do

docker run myr

Further Reading

By default, the output of R scripts is saved in a file owned by root. That's usually okay - the file is read-only, but that's almost always how you'll use the output file anyway. A description of how I allow non-root permissions can be found here.

The little bit I know about creating Docker images comes from this document.

You can view the Dockerfile for the base that I've built on here.