Where randomness is the king

Automate opening bash shell on a running docker

2017-03-06

Setting up a development environment that is deployable has always been a complicated task for data scientists. In my case, I have a bunch of environments, each designed for different purposes. For example, I use R for time-series forecasting and descriptive statistics, while using Python (with Scikit-Learn, Tensorflow, and sometimes Caffe) for deep learning and reinforcement learning. It is almost impossible for me to have one environment for every purpose.

Docker has saved my life. It’s an elegant solution for every trouble you’ve ever got with environment settings. If you have not read about it, you should do it now.

To make my life easier, I’ve created several bash scripts to automate some docker tasks that I usually do. You can check the list here. My favorite script is to open a bash shell on a running docker. To execute the bash sell command on a particular docker, you need to know its ID, like this:

1
2
3
4
$ route #Get name of the default interface, for example: eth0
$ sudo ethtool eth0
#Look for "Supports Wake-on: g" line, which means WOL supported
$ sudo ethtool -s eth0 wol g #Enable WOL

Since the DockerID will change every time you run a new image, you need to list all of the running dockers and pick the one that you want to access to. This is not a big deal, until you have to do it hundreds times. The following script will list and let you pick your target docker. A simple solution for a small daily issue.


Blog comments powered by Disqus