I am brand new with Docker. I'm trying create a container that will run a Snakemake pipeline. This pipeline will contain R and Python scripts. Eventually, I'll need to add in a conda environment and clone and build a git hub repo. But for now, I'm just trying to get my python and R packages installed correctly.
I started off following the advice from this question to create an environment that has both Python and R.
This is my Dockerfile so far.
FROM ubuntu:latest
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends build-essential r-base python3.9 python3-pip python3-setuptools python3-dev
WORKDIR /app
RUN pip3 install biopython
RUN pip3 install pandas
RUN pip3 install numpy
RUN Rscript -e "install.packages('tidyverse')"
RUN Rscript -e "install.packages('dplyr')"
RUN Rscript -e "install.packages('testit')"
RUN Rscript -e "install.packages('stringr')"
RUN Rscript -e "install.packages('BiocParallel')"
RUN Rscript -e "install.packages('MPRAnalyze')"
COPY test.R /app
CMD ["Rscript", "test.R"]
The test.R script contains this,
library(dplyr)
print("dplyr working!")
library(testit)
print("testit working!")
library(stringr)
print("stringr working!")
library(tidyverse)
print("tidyverse working!")
library(BiocParallel)
print("BiocParallel working!")
library(MPRAnalyze)
print("MPRAnalyze working!")
When I run docker build
, it seems to work just fine. Everything installs.
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 706B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/ubuntu:latest 1.3s
=> [ 1/13] FROM docker.io/library/ubuntu:latest@sha256:dfd64a3b4296d8c9b 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 65B 0.0s
=> CACHED [ 2/13] RUN apt-get update && apt-get install -y --no-install- 0.0s
=> CACHED [ 3/13] WORKDIR /app 0.0s
=> CACHED [ 4/13] RUN pip3 install biopython 0.0s
=> CACHED [ 5/13] RUN pip3 install pandas 0.0s
=> CACHED [ 6/13] RUN pip3 install numpy 0.0s
=> [ 7/13] RUN Rscript -e "install.packages('tidyverse')" 893.1s
=> [ 8/13] RUN Rscript -e "install.packages('dplyr')" 12.1s
=> [ 9/13] RUN Rscript -e "install.packages('testit')" 2.8s
=> [10/13] RUN Rscript -e "install.packages('stringr')" 4.0s
=> [11/13] RUN Rscript -e "install.packages('BiocParallel')" 1.4s
=> [12/13] RUN Rscript -e "install.packages('MPRAnalyze')" 1.4s
=> [13/13] COPY test.R /app 0.0s
=> exporting to image 1.3s
=> => exporting layers 1.3s
=> => writing image sha256:328a4d8297eb16cef5f415b1067a1592d538db3ce15f9 0.0s
=> => naming to docker.io/library/wut
But when I try to run docker run
it doesn't look like it is working.
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
[1] "dplyr working!"
[1] "testit working!"
[1] "stringr working!"
Error in library(tidyverse) : there is no package called 'tidyverse'
Execution halted
Any ideas as to what is going on? I'm open to new approaches to solving this, as long as I can eventually install a conda environment and clone the github repo (linked above).