Siv Scripts

Solving Problems Using Code

Wed 28 June 2017

Coding in Containers: 30 Day Challenge

Posted by Aly Sivji in Thoughts   

I'm taking an Introduction to Tensorflow training class thru Safari this week. We were given a choice of setting up our classroom environment either in Conda or inside of a Docker container.

Ever since Anaconda started getting in my way during this year's PyCon sprints, I have been moving my development away from conda and into other virtual environment tools that are part of the Python ecosystem. Still have conda installed on my system (and, yes, the sticker is still on my laptop), but it needs to be activated it through a bash function:

$  gogoconda
Conda is activated

Now I'm all in Python 3.6.1, virtualenv, and virtualenvwrapper as part of my default Python install. Even went as far as adding alias python='python3' and alias pip='pip3' to the bottom of my .bash_profile.

I really didn't want to go back to Conda for a single workshop, so I decide to fire up Docker and docker build an image from the provided Dockerfile. A few minutes (and a docker run) later, I'm SSH-ed into a container and I notice that the course material are inside of the container with me. That could be a problem... whatever changes I make will disappear once this container is removed.

As stated in the Docker docs, the best way to store data is through the use of a data volume, i.e. a persistent folder on the local machine that is running the Docker Engine. After fixing the Dockerfile and rebuilding the image, I initialize a new container using the -v /full/path/to/local/folder:/full/path/to/folder/inside/container flag as part of the docker run command.

Now, the data inside of my container is actually stored in a folder on my local drive. My development environment, containing all the required dependencies for my project, is completely isolated from everything else on my system.

Boom 🐳 🐳 🐳

Portability just like that. No more worrying about hardware failures and having to spend hours getting my system back to the state where everything just worked. No wonder everyone loves Docker!


The Challenge

During the month of July, I will be doing all my development work inside of Docker containers. No matter how trivial the task, it will be done inside of a container.

Not sure how I'm going to do this at work since Docker for Windows requires Win10 and I'm stuck with Win7. Might have to run a Debian VM or use Docker Toolbox. That's on me.

I plan to keep semi-detailed notes while I experiment and figure out what workflow works best. Building off a slim base image? Have a "batteries included" ready-to-go container for data analysis projects? Stay tuned!


 
    
 
 

Comments