Fun with Docker

I want to play with Docker but need to get some fundamentals down straight. A couple of reasons, I want to utilize Shiny Studio and I would also like to use Continuous Development functions from Gitlab.

Here are some fundamental Docker commands that I took from this tutoral by rOpenSci Labs

The first FROM

The docker image you want to use.

FROM rocker/verse:3.3.2

The RUN command executes shell commands. Common usage would include install required packages.

RUN R -e "install.packages('gapminder', repos = 'http://cran.us.r-project.org')"

The ADD command allows you to add files

ADD analysis.R /home/rstudio/

Build the image

docker build -t my-r-image .

Launch the image.

docker run --rm -p 8787:8787 my-r-image

The period

Below is a .gitlab-cy.yml file; it seems there are some similarities between the Docker commands above.

image: rocker/verse:3.4.1

pages:
  stage: deploy
  script:
  - Rscript -e "bookdown::render_book('index.Rmd', 'all', output_dir = 'public')"
  artifacts:
    paths:
    - public
  only:
  - master

I tried these steps on my Linux box and was getting a permission denied error. An extra step of creating a user group is required.

The video in this tutorial is what helped me figure it out.

I will save for another post on why in the world you would want to do these things!

Avatar
Kevin Gilds
Nonprofit Data Professional

My interest include nonprofit data and programs.

Related