Skip to content

Instantly share code, notes, and snippets.

@davidtedfordholt
Created April 24, 2020 16:55
Show Gist options
  • Save davidtedfordholt/06b5ffa6862f59e98dac0a6021a24584 to your computer and use it in GitHub Desktop.
Save davidtedfordholt/06b5ffa6862f59e98dac0a6021a24584 to your computer and use it in GitHub Desktop.
Simple Dockerfile for R
## Base image
FROM rocker/r-base
# Copy R scripts to container
COPY / ./
# Execute when container is BUILT:
# sudo docker build -t example_container .
RUN Rscript setup.R
# Execute when container is RUN:
# sudo docker run --rm example_container
CMD Rscript run.R
print("I built a container!")
print("I am building a container.")
@davidtedfordholt
Copy link
Author

davidtedfordholt commented Apr 24, 2020

My first swag was just

FROM rocker/r-base
RUN R -e 'print("I am building a container.")'
CMD R -e 'print("I built a container!")

but that seems a bit hard to extrapolate from. :)

@davidtedfordholt
Copy link
Author

Or, for my very favorite @jtbaker:
echo -e "FROM rocker/r-base\n COPY / ./\n CMD Rscript run.R" >> Dockerfile && echo "print('I love you, Jason')" >> run.R && docker build -t ex . && docker run --rm ex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment