A Collection of Docker Images that I Find Useful
(keep updating)
Updated 04/14: Tensorflow
Updated 04/12: Ubuntu
This image is particularly useful when you want to utilize some of the command
line tools that come conveniently with linux systems. Also, I manage my Python
packages using conda, and there are times when I just need a package temporarily
yet it is not available via conda. For example, I recently defended my thesis,
and would like to make ad academic pedigree for myself using the excellent
geneagrapher. The original code
was written in Python2
but my local machine has Python3
. Therefore I
considered using the base Ubuntu docker image:
docker pull ubuntu
docker run -it --rm ubuntu bash # use the bash inside the ubuntu container
############# the following code is run within the container
apt update
apt install python2.7 python-pip
apt install python-pydot python-pydot-ng graphviz
pip install geneagrapher
The code above installs all the necessary tools for making the academic pedigree
tree. The image is now available at
DockerHub. You can avoid all
the previous steps by using docker pull xueyishu2436/geneagraph
.
Next we can make a directory to temporarily store all trees we have drawn:
mkdir temptrees
cd temptrees
## take the great statistician Grace Wahba as an example; ID found on math genealogy
## this step obtains her information and saves it to a dot file; could take a while
## -a: ancestors
## -d: descendants
ggrapher -f "GW.dot" -a -d 32951
## visualize!
dot -Tpdf GW.dot > GW.pdf
Finally, a .pdf
is made, but within the container! How do we move it to the
local machine? In a new terminal window, type
docker ps # look for the containerName in the rightmost column
docker cp containerName:/temptrees/. ~/Downloads/
cd ~/Downloads/temptrees
open GW.pdf
Updated 04/10: Rstudio
In R, we sometimes encounter non-compatibility issues and receive a message saying “package xxx is not available (for R version xxx)”. A solution to this is to have multiple versions of R available, which can easily mess things up. Docker provides a solution - we are able to run a different version of R inside the docker container. Folks at rocker-org keep a collection of images on dockerhub, which include the base R, R plus rstudio server, R plus tidyverse, R plus verse, R for spatial statistics, ….
Take R plus rstudio server as an example. All we need to do is to run:
docker pull rocker/rstudio
and download the rstudio image. Next, type
docker run --rm -p 8787:8786 rocker/rstudio
to start the docker container. The option --rm
ensures that when we quit the
container, the container is deleted. The option -p
specifies the mapping
between ports of the docker container and local machine: from container’s port
8786 to localhost’s port 8787. Once the container is running, open up a browser
window and enter “localhost:8787” as the url. You should be prompted to a login
page of rstudio server. The initial username is “rstudio”, and you will be
prompted to set the password before you successfully run the image tfor the
first time.
Enjoy!
Updated 04/05: Julia
Installation of Julia
on macOS often involves downloading the installer from
its [official website] (https://julialang.org/downloads/), granting various
system accesses, and setting up PATH
, etc.. Using Docker, Julia
can be
installed easily via:
docker pull julia
docker run -it --rm julia
This will start julia from the command line.