This project is named Baker
because it provides a Doc
ker
image for Bayesian analysis. In particular, it enables
PyMC3
with Jupyter
and miniconda3
Stan
using R
through rstan
and other related packagesBUGS
, in particular OpenBUGS
, using R2OpenBUGS
JAGS
using rjags
The website for this project is available at here. The project’s goal is to help
If you find this project helpful, please consider staring it and sharing the words. If you have any comments, concerns, or questions, please feel free to raise an issue.
I was first introduced to WinBUGS
in an undergraduate Bayesian analysis course. Not knowing much modern computing technologies at the time, I had to visit the lab to use their Windows machines which have the software installed. Then, a couple years flew by, I took another Bayesian class in grad school which also required OpenBUGS
. To make things worse, iOS dropped support for 32 bit programs in the middle of the semester after I spent significant amount to time configuring wine
, OpenBUGS
, and R2OpenBUGS
on my MacBook. I know now is the time.
Be the change you wish to see. —- Mahatma Gandhi
Some basic (very little) general knowledge of Docker
is needed. If one is interested in learning more, this tutorial is a great source. We will present below a few common use cases.
The Dockerfile
of this project is based on rocker/verse:latest
, therefore sharing many similar usage. For example, to set up a rstudio server
on local host, run
docker run \
-d \
--rm \
-p 8787:8787 \
-e USER=<username> \
-e PASSWORD=<password> \
--name <container_name> \
haoencui/baker
Then, visit localhost:8787
in your browser with specified <username>
and <password>
.
-d
: to start a container in detached mode;--rm
: automatically remove the container when it exits;-p
: publish container port to host, hostPort:containerPort
. One can pass multiple -p
options. 8787
is used by rstudio server
;-e
: set environment variable, i.e. username and password for rstudio server. PASSWORD
is required and cannot be "rstudio"
. If USER
is omitted, then "rstudio"
is used as default; and--name
: name of container for identification, can be omitted.The --volume
option (or -v
in short) is also convenient to mount volume from local host (e.g. your laptop). For example, adding
to the aforementioned docker run
command will connect ~/WORKSPACE
inside the Docker
container with current working directory (pwd
) on your local host, i.e. the file system under the directory is shared and hence modification will be reflected in real time. For additional details on running rstudio server
, please read rocker wiki page.
To set up a jupyter lab
on local host, run
# WARNING: THIS PROBABLY WON'T WORK AND IS RUN AS ROOT WITHOUT AUTH
docker run \
-d \
--rm \
-p 9999:9999 \
--volume $(pwd):/WORKSPACE \
haoencui/baker \
/bin/bash -c \
"jupyter notebook --allow-root --ip=0.0.0.0 --port=9999 --no-browser --NotebookApp.token='' --NotebookApp.password=''"
Then, visit localhost:9999
in your browser without the need to sign in.
If one needs to peek into the Docker
container while it’s running, use
to find the <container-id>
and run as root
user via
and this will start a bash
shell running inside the Docker
container as identified by its ID.
For one-off scripts, one can execute them via
For example, <some-command>
can be echo $HOME && echo $USER
or Rscript file.R
. Don’t forget the --volume
option if you want to access or modify files on local host. But note that this will run as the root
user so don’t do something too crazy if you are also exposing your laptop’s file system.
Last but not least, don’t forget to shutdown the containers using
and remove stopped containers, if you’d like
Users wanted: Please try out this project and let me know your thoughts. There are a few examples on the project website if you don’t have a Bayesian model handy.
I hacked together this project over a weekend before Christmas. This is also the first Dcokerfile
I’ve ever built, so there are probably a lot of problems and room for improvements. Please feel free to raise an issue and / or directly contribute. Your help is greatly appreciated.
This project is greatly inspire by the rocker project, [@jrnold's `rstan` `Dockerfile`](https://hub.docker.com/r/jrnold/rstan/dockerfile), and [@jonzelner's `rstan` `Dockerfile`](https://hub.docker.com/r/jonzelner/rstan/dockerfile).
Special thanks to [@jsal13](https://github.com/jsal13) and [@patrick-boueri](https://github.com/patrick-boueri) for helping me debug my messy docker build
logs.