I've heard a bit about docker and figured it would be neat to play around with but didn't really have anything specific in mind. The dependencies of this blog have been increasing and I recently had to spend several hours debugging things to get my site to generate, so I figured this was as good a time as any to finally test out docker. I generate this blog with the python framework pelican and a plugin which allows me to generate content from jupyter notebooks. There is also another interesting plugin for incorporating .Rmd files, which I hope to take a look at at some point. Since I'm using the anaconda python distribution I probably could have just done something like

conda list --export > blog_reqs.txt
conda create -n blog --file blog_reqs.txt

and then built my blog using this conda environment, but if I move towards creating some content in .Rmd files this solution would not address dependency issues with R, plus I want to try docker!

As a side note, if you haven't heard of docker, there is an interesting talk here to motivate its use and a nice introductory tutorial here.

I created a Dockerfile to generate my blog container that looks like

FROM debian:8.4

MAINTAINER Matthew Gilbert <>

RUN apt-get update && apt-get install -y \
    wget git bzip2 make vi

RUN mkdir -p /home/matthew/Projects

RUN echo 'export PATH=/opt/conda/bin:$PATH' > /etc/profile.d/ && \
    wget --quiet && \
    /bin/bash / -b -p /opt/conda && \
    rm /

ENV PATH /opt/conda/bin:$PATH

# colour no longer rendering with pelican 3.7
RUN conda install markdown==2.6.6
RUN pip install pelican==3.6.3

Then to generate my blog I just build the container, start it up exposing a port, build the static pages and serve them to the exposed port.

matthew@matthew-asus ~ $ docker build -t blog ~/Projects/dockers/blog/
matthew@matthew-asus ~ $ cd ~/Projects
matthew@matthew-asus ~ $ git clone --recurse-submodules 
matthew@matthew-asus ~ $ cd blog
matthew@matthew-asus ~ $ docker run -v $PWD:/tmp/working -w=/tmp/working -itp 8000:8000 blog bash
root@79cc71ca90f1:/tmp/working# make html
pelican /tmp/working/content -o /tmp/working/output -s /tmp/working/ 
Done: Processed 2 articles, 0 drafts, 1 page and 0 hidden pages in 1.38 seconds.
root@79cc71ca90f1:/tmp/working# make serve
cd /tmp/working/output && python -m pelican.server

From there I can inspect them from a web browser on the host at localhost:8000/ and if all looks good can deploy them to Github for hosting.