Build IPython Notebook environment with boot2docker

2016/6/5 postscript

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

Introduction

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.

Target

Create an IPython Notebook environment in a Windows environment and try it. As a feeling

So

  1. Create a boot2docker virtual environment in the Windows environment
  1. Create an IPython Notebook container on the boot2docker virtual environment

Let's think about a method like this.

What to use

How to make

The working folder is C: \ test \ boot2docker-vboxsf.

boot2docker Creating a virtual environment

  1. 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.

  1. 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"
    
  2. 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.

Launch the IPython Notebook container

Let's create an IPython Notebook container in boot2docker. here,

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.

Operation check

Try accessing http://192.168.33.11:8080 from your browser.

ipythonnotebook.png

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.

Recommended Posts

Build IPython Notebook environment with boot2docker
Parallel computing with iPython notebook
Play with Jupyter Notebook (IPython Notebook)
Run Apache-Spark with IPython Notebook
Graph drawing with IPython Notebook
Use Bokeh with IPython Notebook
Data analysis environment construction with Python (IPython notebook + Pandas)
Pepper-kun remote control environment construction with Docker + IPython Notebook
R & D life with iPython notebook
Build python virtual environment with virtualenv
Build Mysql + Python environment with docker
Build Flask environment with Dockerfile + docker-compose.yml
Build PyPy execution environment with Docker
Build a comfortable psychological experiment / analysis environment with PsychoPy + Jupyter Notebook
Build jupyter notebook environment with Visual Studio Code (VS Code) Mac version
Easily build a development environment with Laragon
Use apache Spark with jupyter notebook (IPython notebook)
Build a Tensorflow environment with Raspberry Pi [2020]
Build a Fast API environment with docker-compose
Build Python environment with Anaconda on Mac
"LIVE" HTML presentation with IPython 3.0.0-dev, IPython Notebook
[Linux] Build a jenkins environment with Docker
Build a python virtual environment with pyenv
Build a modern Python environment with Neovim
Build AI / machine learning environment with Python
Rich cell output with Jupyter Notebook (IPython)
Build NGINX + NGINX Unit + MySQL environment with Docker
[Linux] Build a Docker environment with Amazon Linux 2
ipython notebook installation
IPython Notebook Recommendations
Build a C language development environment with a container
How to debug with Jupyter or iPython Notebook
Build a WardPress environment on AWS with pulumi
Build Django + NGINX + PostgreSQL development environment with Docker
Analytical environment construction with Docker (jupyter notebook + PostgreSQL)
Build the fastest Django development environment with docker-compose
Build python environment with pyenv on EC2 (ubuntu)
Create execution environment for each language with boot2docker
Build Python development environment with Visual Studio Code
Go (Echo) Go Modules × Build development environment with Docker
Build a python environment with ansible on centos6
[Python] Build a Django development environment with Docker
Create a python3 build environment with Sublime Text3
Try using conda virtual environment with Jupyter Notebook
Build a Django environment with Vagrant in 5 minutes
[Memo] Build a virtual environment with Pyenv + anaconda
Build a virtual environment with pyenv and venv
Build a Django development environment with Doker Toolbox
Graph drawing with jupyter (ipython notebook) + matplotlib + vagrant
Build a Python environment with OSX El capitan
Quickly build a Python Django environment with IntelliJ
Build PyPy and Python execution environment with Docker
Build a Python machine learning environment with a container
Build a python execution environment with VS Code
Create a table of contents with IPython notebook
R environment construction with Jupyter (formerly IPython notebook) (on OS X El Capitan 10.11.3)
Virtual environment construction with Docker + Flask (Python) + Jupyter notebook
Build a python virtual environment with virtualenv and virtualenvwrapper
Build a python environment for each directory with pyenv-virtualenv
EC2 provisioning with Vagrant + Jupyter (IPython Notebook) on Docker
Build a machine learning application development environment with Python