I didn’t really understand what Docker was for until yesterday. I mean, containers. Cool. Whatever.
Yesterday I was trying to get an environment for some neural networks experiments (exciting post upcoming featuring THE QUEEN!). And it was, well, horrible. I needed Ubuntu 14.04, and I thought I was going to have reinstall my operating system, and I am apparently past the age when that was fun. I needed all these C++ things and nothing was working and I did not know what to do.
AND THEN I REMEMBERED ABOUT DOCKER.
I downloaded an Ubuntu 14.04 image, and suddenly I just had Ubuntu 14.04! And I could INSTALL THINGS ON IT. Without worrying! And if I put them in a Dockerfile, it would let OTHER PEOPLE set up the same environment. Whoa.
And it’s fast! It’s not like a virtual machine which takes forever to start – starting a Docker container is just like, well, starting a program. Fast. Now I can run all my experiments inside the container and it’s not a problem.
Here’s what the Dockerfile looks like! It was really easy! I just do the same random crap I might do to set up my environment normally (do you see where I install some packages, and then replace the sources.list from, uh, Debian wheezy, with an Ubuntu sources.list in the middle? yeah I did that.). But I don’t have to worry about screwing up my computer while doing it, and then even if it’s a mess, it’s a reproducible mess!
It includes the following gem:
RUN cd /opt/caffe
&& cp Makefile.config.example Makefile.config
| base64 -d \ | patch -u Makefile.config
where I edited a file manually, made a patch, base64 encoded it, and just pasted the string into the Dockerfile so that the edits I needed would work.
The next time I need to compile a thing with horrible dependencies that I don’t have on my computer and that conflict with everything, I’m totally using Docker.