LoginSignup
4
4

More than 5 years have passed since last update.

OpenCV入りJupyter NotebookのDockerfile

Posted at

Anaconda最高!!

Anacondaに感動したので、
メモをかねて残そうかと思いました。
(知るのがちょっと遅かった。。。)

昔OpenCV入れるのに、
gitからソース取ってきて、cmakeして...っていう通常の流れをして、
(VM上で行っていたこともあり)リソース足りなくて失敗した、とか
成功しても非常に時間がかかった、という辛い経験があったのですが
Anaconda(conda)だと簡単に入れられました。

Anacondaのインストールの際には
ほかにもnumpy,scipy等々絶対使うだろ!ってものも入ってくるのですね!

Dockerfile

Dockerfile書いたので
同じように辛い思いをした方がいれば参考になれば幸いです。

FROM ubuntu:16.04

RUN apt-get update && \
                    # for Anaconda
    apt-get install -y wget bzip2 \
                    # for OpenCV
                       libgtk2.0-0

# Anaconda3-4.2.0 install
RUN wget https://repo.continuum.io/archive/Anaconda3-4.2.0-Linux-x86_64.sh && \
    bash Anaconda3-4.2.0-Linux-x86_64.sh -b && \
    rm -f Anaconda3-4.2.0-Linux-x86_64.sh

ENV PATH $PATH:/root/anaconda3/bin

# OpenCV install
RUN conda install -c https://conda.anaconda.org/menpo opencv3

# make jupyter directory
RUN mkdir /opt/jupyter/ && \
    jupyter notebook --generate-config && \
    sed -i -e "s/#c.NotebookApp.ip = 'localhost'/c.NotebookApp.ip = '*'/" /root/.jupyter/jupyter_notebook_config.py

CMD cd /opt/jupyter/ && \
    jupyter notebook

起動

蛇足かもしれませんが、ビルド&起動のコマンドです。

ビルド

docker build -t <image_name> <dockerfile_directory>/.

起動

docker run -d --name <container_name> -p 8888:8888 <image_name>
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4