Here is an example of a simple Docker file.
In this case, we are reusing the r-base image with tag latest;
we then copy a bash script checkit.sh; and finalize with Rscript installing
the igraph R package.
FROM r-base:latest
COPY checkit.sh .
RUN Rscript -e 'install.packages("igraph")'
CMD ["bash"]Where checkit.sh has the following contents:
cd /home/docker/
R CMD check netplotTo build the docker container, named docker-example, use:
sudo docker build --compress -t docker-example .
This image is now available to be used in your computer. In case you want it to release it to https://hub.docker.com, you'd need to do the following:
sudo docker login # follow the prompts
sudo docker tag docker-example:latest uscbiostats/docker-example:latest
sudo docker push uscbiostats/docker-example:latestWhere uscbiostats is the name of the account to which you will be pushing this
image. This way, users who have access to docker can simply type
sudo docker pull uscbiostats/docker-example:latestTo have access to this image that contains R with igraph installed.
To execute it interactively (with R), type:
sudo docker run -i docker-example R
Or if you want to run Rscript:
sudo docker run -i docker-example Rscript -e '1 + 1'
If you want to run it while having access to the current directory:
sudo docker run -i -v$(pwd):/home/ -w/home/ docker-example Rscript -e '1 + 1'
https://docs.docker.com/engine/security/rootless/ while installing the rootless mode, I encountered a problem regarding a missing binary in Ubuntu 18.04. This repository had an issue with the problem:
In my case, I ran the following steps:
- cd /usr/bin
- sudo curl -o slirp4netns --fail -L https://github.com/rootless-containers/slirp4netns/releases/download/v1.1.10/slirp4netns-$(uname -m)
- chmod +x slirp4netns