I wrote it because it is good to use Docker Toolbox and Jupyter Notebook now. My best practices when running Jupyter Notebook in a local environment
I've been doing data analysis and other tasks on a daily basis, and I'm writing Python code each time, but as expected (in my specifications), the detailed code gets messed up and I use which one later for what. I don't know what it was.
So I'm interested in IPython Notebook. When I was a graduate student, I would be happy if the data analysis program and the analysis results obtained from it were arranged together to help understand the program. I'm talking about something like this, and I think I can easily realize this. A memo that I tried in such a flow.
Create an IPython Notebook environment in a Windows environment and try it. As a feeling
So
Let's think about a method like this.
The working folder is C: \ test \ boot2docker-vboxsf
.
vagrant init
in your working folder
> vagrant init dduportal/boot2docker
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
A Vagrantfile for using dduportal / boot2docker is generated in the working folder.
Rewrite the network settings in the Vagrantfile
This time, I decided to use the boot2docker environment only for access from the host, not port forwarding, and this time I will shake 192.168.33.11
.
The part that was originally commented out was changed as follows.
# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: "192.168.33.11"
Create and start a virtual environment by vagrant up
in the working folder
> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'dduportal/boot2docker'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'dduportal/boot2docker' is up to date...
==> default: Setting the name of the VM: boot2docker-vboxsf_default_1412262151282_87930
==> default: Fixed port collision for 2375 => 2375. Now on port 2200.
==> default: Fixed port collision for 22 => 2222. Now on port 2201.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 2375 => 2200 (adapter 1)
default: 22 => 2201 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2201
default: SSH username: docker
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => C:/test/boot2docker-vboxsf
Like the last message, / vagrant
on the boot2docker virtual environment is automatically shared with the host C: \ test \ boot2docker-vboxsf
.
This completes booting the boot2docker environment. You can SSH into a virtual environment with vagrant putty
.
Using username "docker".
Authenticating with public key "imported-openssh-key"
## .
## ## ## ==
## ## ## ## ===
/""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\______/
_ _ ____ _ _
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
boot2docker: 1.2.0
master : e75396e - Fri Aug 22 06:03:48 UTC 2014
docker@boot2docker:~$ ls -la /vagrant
total 5
drwxrwxrwx 1 docker staff 0 Oct 2 15:02 ./
drwxr-xr-x 17 root root 400 Oct 2 15:03 ../
drwxrwxrwx 1 docker staff 0 Oct 2 15:02 .vagrant/
-rwxrwxrwx 1 docker staff 4951 Oct 2 15:02 Vagrantfile
docker@boot2docker:~$
Make sure you can see the contents of C: \ test \ boot2docker-vboxsf
from the directory / vagrant
and the changes will reflect each other.
Let's create an IPython Notebook container in boot2docker. here,
C: \ test \ boot2docker-vboxsf \ notebook
(/ vagrant / notebook
) to act as the data directory for IPython Notebook8080
Try as. Execute the following command on the boot2docker environment.
docker@boot2docker:~$ mkdir /vagrant/notebook
docker@boot2docker:~$ docker run -d -p 8080:8888 -v /vagrant/notebook:/notebook skitazaki/python34-ipython
Unable to find image 'skitazaki/python34-ipython' locally
Pulling repository skitazaki/python34-ipython
...
3f1228b888bd: Download complete
(Container ID)
docker@boot2docker:~$
Now, as the / notebook
of the IPython Notebook container, / vagrant / notebook
in the boot2docker environment will correspond, and the C: \ test \ boot2docker-vboxsf \ notebook
of the Windows host will correspond to this. ..
If there are no particular errors, this completes the startup. Just in case, use docker ps
to check that the container is running.
Try accessing http://192.168.33.11:8080
from your browser.
If you create a Notebook (for example, Hello) here, you can see that Hello.ipynb
is created in C: \ test \ boot2docker-vboxsf \ notebook
.
Also, if you put the data to be analyzed under this folder, you can read it from the Python code in Notebook as appropriate.
Once again, boot2docker is easy. I will play with this environment for a while.