Skip to content

Commit 3f26dad

Browse files
committed
README.md finished. Also there are some little changes to the "bmo" script".
1 parent 28d1947 commit 3f26dad

File tree

2 files changed

+171
-40
lines changed

2 files changed

+171
-40
lines changed

README.md

Lines changed: 145 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ VISIT https://github.com/josemazo/bmo FOR SEE THIS FILE FORMATTED
77
BMO — ![BMO](https://raw.githubusercontent.com/josemazo/bmo/master/resources/bmo.png "BMO")
88
=================================================================================================
99

10-
A Machine Learning toolbox based on Docker and IPython Notebook.
10+
BMO, pronounced Beemo, is a Machine Learning toolbox based on Docker and IPython Notebook. It's extensible with any tool or package you need beacuse it's like having a mini-Linux inside your Linux!
1111

1212
Content
1313
-------
@@ -17,7 +17,14 @@ Content
1717
2. [nsenter](#12-nsenter)
1818
3. [BMO](#13-bmo)
1919
2. [Usage](#2-usage)
20-
3. [List of Python main packages](#3-list-of-python-main-packages)
20+
1. [Initial considerations](#21-initial-considerations)
21+
2. [Start](#22-start)
22+
3. [Finish](#23-finish)
23+
4. [Kill](#24-kill)
24+
5. [Enter](#25-enter)
25+
6. [Commit](#26-commit)
26+
7. [Status](#27-status)
27+
3. [List of the installed Python main packages](#3-list-of-the-installed-python-main-packages)
2128
4. [License and more](#4-license-and-more)
2229

2330
1. Installation
@@ -28,7 +35,7 @@ Content
2835
* [Docker](https://www.docker.com/)
2936
* [nsenter](https://github.com/jpetazzo/nsenter) and the `docker-enter` utility
3037

31-
Being `BMO` based on `Docker`, and the last one can be installed only on `Linux/x64`, `BMO` is restricted to the same platform. This guide only covers the complete `BMO`installation on `Ubuntu 14.04 (Trusty Tahr)`, but excpet for the `Docker` installation step, you can use this guide with any Linux distribution. So, let's start! But before, you need to download `BMO`. For that open a terminal and execute these commands:
38+
`BMO` is based on `Docker`, and the last one can be installed only on `Linux/x64`, so, `BMO` is restricted to the same platforms. This guide only covers the complete `BMO`installation on `Ubuntu 14.04 (Trusty Tahr)`, but excpet for the `Docker` installation step, you can use this guide with any Linux distribution. So, let's start! But before, you need to download `BMO`. For that open a terminal and execute these commands:
3239
```
3340
$ wget https://github.com/josemazo/bmo/releases/download/v0.1/bmo-v0.1.tar.gz
3441
$ tar -zxvf bmo-v0.1.tar.gz
@@ -40,7 +47,7 @@ $ cd bmo/
4047

4148
If you are not using `Ubuntu 14.04 (Trusty Tahr)` you can visit the [`Docker` installation page](https://docs.docker.com/installation/) for an extensive documentation.
4249

43-
**Important**: after installing `Docker` you need to be sure that it can run without the use of `sudo`.
50+
**Important**: after installing `Docker` you need to be sure that it can run without the use of `sudo`. If you are using `Ubuntu 14.04 (Trusty Tahr)`, this guide will show you how to do it.
4451

4552
In the case you are under `Ubuntu 14.04 (Trusty Tahr)` you can follow the next instructions.
4653

@@ -75,16 +82,16 @@ $ sudo service docker restart
7582

7683
Loogout and log back in and check the version of `Docker` again:
7784
```
78-
$ sudo docker version
85+
$ docker version
7986
```
8087

81-
If you get the same output as before and nothing talking about permissions you have `Docker` installed. Congratulations!
88+
If you get the same output as before and nothing talking about permissions you have `Docker` installed correctly. Congratulations!
8289

8390
### 1.2. nsenter
8491

85-
`nsenter` is needed for get a prompt of the `BMO docker image` when this is running (as a `container`) without using `ssh`. You can read [here](http://jpetazzo.github.io/2014/06/23/docker-ssh-considered-evil/) why you shouldn't use `ssh` in a `Docker container`.
92+
`nsenter` is needed for get a prompt of the `BMO Docker image` when this is running without using `ssh`. You can read [here](http://jpetazzo.github.io/2014/06/23/docker-ssh-considered-evil/) why you shouldn't use `ssh` with `Docker`.
8693

87-
For install `nsenter` you can visit [this repo](https://github.com/jpetazzo/nsenter) and follow the instructions detailed there **or** you can trust me and copy a compiled version that I provide in the `nsenter` folder:
94+
For install `nsenter` you can visit [this repo](https://github.com/jpetazzo/nsenter) and follow the instructions detailed there **or** you can copy a compiled version that is provided in the `nsenter` folder:
8895
```
8996
$ sudo cp nsenter/nsenter nsenter/docker-enter /usr/local/bin/
9097
```
@@ -93,22 +100,145 @@ $ sudo cp nsenter/nsenter nsenter/docker-enter /usr/local/bin/
93100

94101
### 1.3. BMO
95102

96-
You really don't need to install anything, but you need to download or build the `BMO Docker image`. There are no difference for use `BMO` between download or build the image. But if you are a `Docker` user and you want to modify the image, you need to build it. In the other case, it's is preferable to download the image because it's faster, a lot.
103+
You really don't need to install anything, but you need to download or build the `BMO Docker image`. There are no difference between download or build the `image`. But if you are a `Docker` user and you want to modify the image, you need to build it. In the other case, it's is preferable to download the image because it's faster, a lot.
104+
105+
So, to download:
97106
```
98107
./bmo -i
99108
```
100109

110+
Or, if you decide to build it:
111+
```
112+
./bmo -ib
113+
```
114+
101115
Wait, and that's all. You are finished with the installation.
102116

103117
2. Usage
104118
--------
105119

106-
**Working on this section**
120+
### 2.1. Initial considerations
121+
122+
Before start explaining how to use `BMO`, it would be nice to _briefly_ know how `Docker` works. `Docker` takes an `image`, something like in a virtual machine, and boots a `Linux` in your running `Linux`, something like a virutal machine. So, what is the difference? It's a little bit complicated, but you can read about what `Docker` is [here](https://docs.docker.com/introduction/understanding-docker/). The point here is that you will have much better performance that in virtual machine, in most cases, the same as if you run your sofware from your native machine, and this is very important when you are dealing with `Machine Learning`.
123+
124+
In summary, the main thing about `Docker` is that you have `images` and `containers`. A `container` is a running instance of an `image`, so you can have multiple `containers` from the same `image`. And what happens when you install some software or you create some files in a `container`? You can lose them if you remove the `container`, but you only need to commit the changes to an `image`, kind of _super easy_.
125+
126+
You may now be thinking that using `BMO`, having `Docker` in the middle, can be very difficult. But don't worry, for that, a `Python` script is provided, called `bmo`, something like a very basic `command line utility` for make your life easier. But if you are `Docker` pro-user you can take a look to the `Dockerfile` and the `bmo` script to understand everything. Also, for the last ones, at the end of the `bmo` script you have the full list of `Docker commands` that the script uses.
127+
128+
**Important**: if you aren't a `Docker` pro-user, you must know that if you use `Docker` without use the `bmo` script, a proper behaviour is not totally guaranteed.
129+
130+
Let's see the main use cases. If you need some more help, you can run:
131+
```
132+
./bmo --help
133+
```
134+
or you can become a `Docker` pro-user reading [this guide](https://docs.docker.com/userguide/). You will thank yourself for reading it, beacause `Docker` is prety awesome. Also, in that help, it's never mentioned the word `container`, it's used the concept `Docker image`, for try to abstract the logic behind `Docker`.
135+
136+
### 2.2. Start
137+
I
138+
For start using the `IPython Notebook` that `BMO` provides, you only need to execute the next command:
139+
```
140+
./bmo -s
141+
```
142+
143+
The output that you are seeing is a `Docker` output. The `bmo` script always shows them, so you can look for help if any error ocurrs.
144+
145+
After that, open your Internet browser and visit:
146+
```
147+
http://localhost:8888/
148+
```
149+
150+
Now you are in the IPython Notebook environment. You can visit [this link](http://ipython.org/notebook.html) for get more information about this awesome tool.
151+
152+
The directory that you are seeing in your browser it's the `notebooks` folder inside the root of the `BMO Docker container`. This directory corresponds to the `notebooks` folder that is inside the current directory in your terminal. That folder will contain your notebooks.
153+
154+
**Important**: `Docker` have a little problem with the files that it creates outside the `container`. The owner of these files is `root`. For change that, you can run the next command everytime you need:
155+
```
156+
./bmo -o
157+
```
158+
159+
### 2.3. Finish
160+
161+
If you have finished your work with the `IPython Notebook` server for this sesion, you can finish the `BMO Docker container` with:
162+
```
163+
./bmo -f
164+
```
165+
166+
This will finish the `container` and remove its reference from `Docker`.
167+
168+
If you want to finish the `container` without remove its reference, for example, for [save changes](#26-commit), you can execute:
169+
```
170+
./bmo -fo
171+
```
172+
173+
After doing whatever you need, execute the next command for remove the `Docker` reference:
174+
```
175+
./bmo -rm
176+
```
177+
178+
Also, after that, it's the perfect time for change the owner of the notebooks with:
179+
```
180+
./bmo -o
181+
```
182+
as we saw in the previous section.
183+
184+
**Important**: remember that for start the `BMO Docker container` again you need that its `Docker`reference is deleted.
185+
186+
### 2.4. Kill
187+
188+
Please, execute a `kill` command only when the `BMO Docker container` doesn't respond or became frozen, it's your last resort. For kill it, you can execute:
189+
```
190+
./bmo -k
191+
```
192+
193+
As the `finish` command, the `kill` one also can be executed without remove the `BMO Docker container` reference:
194+
```
195+
./bmo -ko
196+
```
197+
198+
Take a look to the [previous section](#23-finish) for see how to deal with the `Docker` reference after kill the `conainter` without remove it.
199+
200+
### 2.5. Enter
201+
202+
If you need some `Python` package, or a `Linux` one, that isn't installed on the `BMO Docker image` you can install them wiht `pip` or `apt-get`. For that, if the `BMO Docker containter` is running, you can execute:
203+
```
204+
./bmo -e
205+
```
206+
207+
You will see a `prompt`. Now your are inside the `container` logged as `root`. Install everything you need and type:
208+
```
209+
exit
210+
```
211+
212+
to return to your machine `prompt`.
213+
214+
**Important**: If you want your changes to be permanent, you need to perform a `commit`.
215+
216+
### 2.6. Commit
217+
218+
If you have made some changes to the `container` that you would like to be permanent you need to `commit` the current `BMO Docker container`. For that you need that the `container` is running or finished, never killed (bad practice) or removed. After check that, execute:
219+
```
220+
./bmo -c
221+
```
222+
223+
And your `container` will be saved in the `BMO Docker image`.
224+
225+
### 2.7. Status
226+
227+
Sometimes you will want to know the state of the `BMO Docker container`. For that, you can use:
228+
```
229+
./bmo -st
230+
```
231+
232+
The possible status of `BMO` are:
233+
* running
234+
* finished: you need to remove the `container` for start `BMO` again
235+
* killed: you need to remove the `container` for start `BMO` again
236+
* non-existent: there isn't any `container` attached to `Docker`, so you can start a new one
107237

108-
3. List of Python main packages
109-
-------------------------------
238+
3. List of the installed Python main packages
239+
---------------------------------------------
110240

111-
Once the `BMO Docker image` has been downloaded or builded, a bunch of Python packages will be installed in the image. Here is a list of the main ones:
241+
Once the `BMO Docker image` has been downloaded or builded, a bunch of Python packages will be installed in the `image`. Here is a list of the main ones:
112242
* beautifulsoup4
113243
* gensim
114244
* ipython[notebook]
@@ -132,4 +262,5 @@ Once the `BMO Docker image` has been downloaded or builded, a bunch of Python pa
132262
-------------------
133263

134264
* This project is released under the `MIT License`.
135-
* The `BMO` name and its logo are property [Cartoon Network](http://www.cartoonnetwork.com/). The logo has been taken from the [Adventure Time wiki](http://adventuretime.wikia.com/) on [Wikia](http://www.wikia.com/).
265+
* The `BMO` name and its logo are property of [Cartoon Network](http://www.cartoonnetwork.com/). The logo has been taken from the [Adventure Time wiki](http://adventuretime.wikia.com/) on [Wikia](http://www.wikia.com/).
266+
* This is a project that will always be growing, and of course, you can contribute.

bmo

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
# BMO command line tool.
44

5-
# Is assumed that you are running this tool from the directory where is the
5+
# It's assumed that you are running this tool from the directory where is the
66
# BMO Dockerfile, that a 'notebooks' folder exists in the same directory and
77
# that you are not running another Docker container
88

9-
# This script doesn't control Docker workflow by itself. It only sends 'Dcoker
9+
# This script doesn't control Docker workflow by itself. It only sends 'Docker
1010
# actions', using mainly the Docker command line tool, and print the output
1111
# without check the Docker BMO container status. It's done that way to get the
1212
# actual Docker status in every command, so, you may look for help if any
13-
# errors ocurr.
13+
# error ocurrs.
1414

1515
# At the end of this file there is a list with the actual commands that this
1616
# script runs.
@@ -104,7 +104,7 @@ def container_status():
104104
index += len('Exited') + 2
105105
exited = line[index:index + 2]
106106
if exited != '-1':
107-
print'BMO status: stopped'
107+
print'BMO status: finished'
108108
else:
109109
print 'BMO status: killed'
110110
sys.exit(0)
@@ -124,7 +124,7 @@ group.add_argument('-h', '--help', action='store_true',
124124
help='show this help message and exit')
125125

126126
group.add_argument('-v', '--version', action='store_true',
127-
help='show this BMO command line tool version')
127+
help='show the version of this tool')
128128

129129
group.add_argument('-i', '--install', action='store_true',
130130
help='download the BMO Docker image from Docker Hub')
@@ -140,20 +140,20 @@ group.add_argument('-s', '--start', action='store_true',
140140
Docker image')
141141

142142
group.add_argument('-sl', '--start-log', action='store_true',
143-
help='same as "-s, --start" but showing IPython logs in \
144-
the terminal')
143+
help='same as "-s, --start" but showing the IPython main \
144+
log in the terminal')
145145

146146
group.add_argument('-b', '--bash', action='store_true',
147147
help='open a terminal in the BMO Docker image without \
148148
launch the IPython Notebook Server')
149149

150150
group.add_argument('-f', '--finish', action='store_true',
151-
help='stop the BMO Docker image and remove the Docker \
152-
reference')
151+
help='finish/stop the BMO Docker image and remove the \
152+
Docker reference')
153153

154154
group.add_argument('-fo', '--finish-only', action='store_true',
155-
help='stop the BMO Docker image without remove the Docker \
156-
reference')
155+
help='finish/stop the BMO Docker image without remove the \
156+
Docker reference')
157157

158158
group.add_argument('-k', '--kill', action='store_true',
159159
help='kill the BMO Docker image and remove the Docker \
@@ -175,7 +175,7 @@ group.add_argument('-o', '--owner', action='store_true',
175175
current user / ask for root password')
176176

177177
group.add_argument('-st', '--status', action='store_true',
178-
help='show if the BMO Docker images is running, stopped, \
178+
help='show if the BMO Docker image is running, finished, \
179179
killed or non-existent (removed)')
180180

181181

@@ -259,47 +259,47 @@ if commands:
259259
'''
260260
List of Docker commands used in BMO
261261
262-
Install
262+
Install: -i, --install
263263
docker pull josemazo/bmo:latest
264264
265-
Install building
265+
Install building: -ib, --install-building
266266
docker build -t josemazo/bmo:latest .
267267
268-
Commit
268+
Commit: -c, --commit
269269
docker commit bmo josemazo/bmo:latest
270270
271-
Start
271+
Start: -s, --start
272272
docker run -d -v $(pwd)/notebooks:/notebooks -p 0.0.0.0:8888:8888 --name bmo josemazo/bmo:latest supervisord
273273
274-
Start log
274+
Start log: -sl, --start-log
275275
docker run -v $(pwd)/notebooks:/notebooks -p 0.0.0.0:8888:8888 --name bmo josemazo/bmo:latest supervisord
276276
277-
Bash
277+
Bash: -b, --bash
278278
docker run -t -i -v $(pwd)/notebooks:/notebooks -p 0.0.0.0:8888:8888 --name bmo josemazo/bmo:latest bash
279279
280-
Finish
280+
Finish: -f, --finish
281281
docker stop bmo
282282
docker rm bmo
283283
284-
Finish only
284+
Finish only: -fo, --finish-only
285285
docker stop bmo
286286
287-
Kill
287+
Kill: -k, --kill
288288
docker kill bmo
289289
docker rm bmo
290290
291-
Kill only
291+
Kill only: -ko, --kill-only
292292
docker kill bmo
293293
294-
Remove
294+
Remove: -rm, --remove
295295
docker rm bmo
296296
297-
Enter
297+
Enter: -e, --enter
298298
docker-enter bmo
299299
300-
Owner
300+
Owner: -o, --owner
301301
sudo chown -R $USER:$USER notebooks
302302
303-
Status
303+
Status: -st, --status
304304
docker ps -a
305305
'''

0 commit comments

Comments
 (0)