Use vim keybindings on Docker-launched Jupyter Notebook

Overview

Recently, I'm reading a statistics book while studying data science, but it can be difficult to imagine just reading a book, so I wanted to do it while writing code at hand using Jupyter Notebook. thought. When writing code with Jupyter Notebook, I wanted to be able to use vim because the tension would not rise unless I could use vim key bindings, but I was a little addicted to it, so I summarized the method.

environment

version
Mac 10.15.3
Docker 19.03.4
docker-compose 1.24.1

Environment construction procedure

Launch a Jupyter Notebook with vim keybindings using Dockerfile and docker-compose.

1. Create a directory for saving notebooks
$ mkdir notebooks
2. Creating a Dockerfile

Dockerfile


FROM jupyter/minimal-notebook:latest

USER root

RUN pip install jupyter_contrib_nbextensions && \
    jupyter contrib nbextension install --user && \
    git clone https://github.com/lambdalisue/jupyter-vim-binding /home/jovyan/.local/share/jupyter/nbextensions/vim_binding && \
    jupyter nbextension enable vim_binding/vim_binding

EXPOSE 10000
CMD ["bash"]
3. Create docker-compose.yml

docker-compose.yml


version: '3'
services:
  data-science:
    restart: always
    build: .
    container_name: 'data-science'
    ports:
      - "10000:10000"
    working_dir: '/root/'
    tty: true
    volumes:
      - ./notebooks:/root/notebooks/
4. Build the container
$ docker-compose up -d --build
5. Log in to the container
$ docker-compose exec data-science bash
6. Launch Jupyter Notebook
/root# jupyter notebook --port 10000 --allow-root

Access the displayed http://127.0.0.1:10000/?token=xxxxxxxxxxxxxxxx.

7. Enable the VIM binding extension

By default, disable is checked in the extension settings, so uncheck it to enable it. スクリーンショット 2020-02-16 9.41.55.png

Now you can use vim on your notebook スクリーンショット 2020-02-16 9.47.41.png

Finally

The method of making vim key bindings available in Jupyter Notebook was quite organized, but I was addicted to it except when I tried various things, so I tried to summarize it myself. Now you can write a comfortable Notebook! (However, this time I made all users root, so it may be better to change that area.)

reference

Recommended Posts

Use vim keybindings on Docker-launched Jupyter Notebook
Use emacs or vim keybindings in IPython notebook
Use pip with Jupyter Notebook
High charts on Jupyter notebook
View PDF on Jupyter Notebook
Use Cython with Jupyter Notebook
Run Jupyter Notebook on windows
How to use Jupyter Notebook
Formatting with autopep8 on Jupyter notebook
Run azure ML on jupyter notebook
Use markdown with jupyter notebook (with shortcut)
Easy to use Jupyter notebook (Python3.5)
Try running Jupyter Notebook on Mac
Use nb extensions with Anaconda's Jupyter notebook
Use Jupyter Lab and Jupyter Notebook with EC2
Start jupyter notebook on GPU server (remote server)
You can use Dash on Jupyter jupyter_dash
Use BigQuery from your local Jupyter Notebook
Clone the github repository on jupyter notebook
GPU check of PC on jupyter notebook
Display histogram / scatter plot on Jupyter Notebook
Build jupyter notebook on remote server (CentOS)
Jupyter Notebook Basics of how to use
Run Jupyter notebook on a remote server
How to use Jupyter notebook [Super Basic]
Use Jupyter Notebook with Visual Studio Code on Windows 10 + Python + Poetry + pyenv-win
Install matplotlib and display graph on Jupyter Notebook
Use jupyter notebook by connecting from another host
Jupyter Notebook memo
[Jupyter Notebook / Lab] 3 ways to debug on Jupyter [Pdb]
Introducing Jupyter Notebook
Launch and use IPython notebook on the network
Powerful Jupyter Notebook
Enable Jupyter Notebook with conda on remote server
[Pythonocc] I tried using CAD on jupyter notebook
Simply display a line graph on Jupyter Notebook
Jupyter on AWS
Jupyter notebook password
Jupyter Notebook memo
Jupyter Notebook Settings-How to use (EC2 Amazon Linux 2)
Try Apache Spark on Jupyter Notebook (on local Docker
Remotely open Jupyter notebook launched on the server
jupyter notebook does not start on mac fish
Easily launch jupyter notebook on AWS and access locally
Run Tensorflow from Jupyter Notebook on Bash on Ubuntu on Windows
Monitor the training model with TensorBord on Jupyter Notebook
Try basic operations for Pandas DataFrame on Jupyter Notebook
EC2 provisioning with Vagrant + Jupyter (IPython Notebook) on Docker
[Windows] [Python3] Install python3 and Jupyter Notebook (formerly ipython notebook) on Windows
How to view progress bar on Jupyter Notebook to see progress
Hello X3DOM on Jupyter
Use pyvenv on Windows
3 Jupyter notebook (Python) tricks
Use Ansible on Windows
Use QuTiP on Windows
Use pip on Windows
Use nim with Jupyter
[Cloud103] # 3 Jupyter Notebook again
[Memo] Display Jupyter Notebook on PC in monospaced font (Mac)
I want to use a virtual environment with jupyter notebook!
Unable to display tensorboard in jupyter notebook on docker (solved)