[Docker] Build Jupyter Lab execution environment with Docker

Those who are likely to fit this article

・ I want to easily build a data analysis environment for the time being. ・ You have an environment where you can use docker. ・ I can understand the contents of the Dockerfile. ・ I can understand linux commands.

Why Docker

・ Isn't it okay to put anaconda on the host? If you install anaconda etc., it will be difficult to uninstall. -Since the entire container can be thrown away, it can be used easily. -You can start up the environment of other people immediately with just one Dockerfile. Environment construction becomes stress-free.

Why anaconda

anaconda is a package that includes Python and the library NumPy SchiPy jupyter required for data analysis. This time, the main tool jupyter is also included, so there is no reason not to use it. I don't want to spend time building the environment. If you have a recent anaconda3, you probably have jupyter, so any version is fine.

The actual Dockerfile is as follows. This OS is described in ubuntu.

Dockerfile


FROM ubuntu:latest
 
RUN apt-get -y update && apt-get install -y \
         wget
 
WORKDIR /opt
RUN wget https://repo.continuum.io/archive/Anaconda3-2020.07-Linux-x86_64.sh && \
sh /opt/Anaconda3-2020.07-Linux-x86_64.sh -b -p /opt/anaconda3

ENV PATH /opt/anaconda3/bin:$PATH

RUN pip install --upgrade pip

WORKDIR /

CMD ["jupyter", "lab", "--ip=0.0.0.0", "--allow-root", "--LabApp.token=''"]

Only the minimum required command execution is executed I will try it. Execute the following command in the directory containing the Dockerfile. docker build .

Execution log


Sending build context to Docker daemon  5.632kB
Step 1/6 : FROM ubuntu:latest
 ---> 4e2eef94cd6b
Step 2/6 : RUN apt-get -y update && apt-get install -y          wget
 ---> Running in ab7a4f407583
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:3 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [221 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-updates InRelease [111 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease [98.3 kB]
Get:6 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [1078 B]
Get:7 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [177 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages [1275 kB]

・ ・ ・ ・ ・ Omitted

Removing intermediate container 5e6f539725f5
 ---> 8f167186b465
Step 5/6 : ENV PATH /opt/anaconda3/bin:$PATH
 ---> Running in da3a2e6521c3
Removing intermediate container da3a2e6521c3
 ---> 7306fc34e088
Step 6/6 : CMD ["jupyter", "lab", "--ip=0.0.0.0", "--allow-root", "--LabApp.token=''"]
 ---> Running in 79cd954afcc4
Removing intermediate container 79cd954afcc4
 ---> 7b05db009f7f
Successfully built 7b05db009f7f

Use the image ID of Successfully built image ID when starting the container.

The container will start by executing the following command. docker run -p 8888: 8888 above image ID

Execution log


[I 03:32:07.355 LabApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[W 03:32:08.010 LabApp] All authentication is disabled.  Anyone who can connect to this server will be able to run code.
[I 03:32:08.034 LabApp] JupyterLab extension loaded from /opt/anaconda3/lib/python3.8/site-packages/jupyterlab
[I 03:32:08.034 LabApp] JupyterLab application directory is /opt/anaconda3/share/jupyter/lab
[I 03:32:08.037 LabApp] Serving notebooks from local directory: /opt
[I 03:32:08.037 LabApp] The Jupyter Notebook is running at:
[I 03:32:08.037 LabApp] http://439ce26ee905:8888/
[I 03:32:08.038 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 03:32:08.042 LabApp] No web browser found: could not locate runnable browser.

You should be able to access it by launching your browser and typing localhost: 8888 in the URL.

Recommended Posts

[Docker] Build Jupyter Lab execution environment with Docker
Pytorch execution environment with Docker
Build docker environment with WSL
Build Couchbase local environment with Docker
Build PlantUML environment with VSCode + Docker
Build environment with vue.js + rails + docker
Build Rails environment with Docker Compose
Build docker + laravel environment with laradock
Build a PureScript development environment with Docker
Build a WAS execution environment from Docker
Build a Wordpress development environment with Docker
Build an environment with Docker on AWS
Build TensorFlow operation check environment with Docker
How to build Rails 6 environment with Docker
Build a Laravel / Docker environment with VSCode devcontainer
Build a WordPress development environment quickly with Docker
Build mecab (NEologd dictionary) environment with Docker (ubuntu)
[Rails] How to build an environment with Docker
[First team development ②] Build an environment with Docker
How to build docker environment with Gradle for intelliJ
Build an environment of Ruby2.7.x + Rails6.0.x + MySQL8.0.x with Docker
Easily build a Vue.js environment with Docker + Vue CLI
[Note] Build a Python3 environment with Docker in EC2
Build Java development environment with WSL2 Docker VS Code
Build WordPress environment with Docker (Local) and AWS (Production)
React environment construction with Docker
Build DynamoDB local with Docker
How to build [TypeScript + Vue + Express + MySQL] environment with Docker ~ Express ~
How to build Rails, Postgres, ElasticSearch development environment with Docker
Build a Node-RED environment with Docker to move and understand
Rails + MySQL environment construction with Docker
Create a Vue3 environment with Docker!
Node.js environment construction with Docker Compose
Environment construction with Docker for beginners
Create SolrCloud verification environment with Docker
Create Laravel environment with Docker (docker-compose)
Build jooby development environment with Eclipse
Build Unity development environment on docker
Build WebRTC Janus with Docker container
Spring Boot gradle build with Docker
Build Go development environment with WSL2 + Docker Desktop + VSCode (Remote --Containers)
Build apache7.4 + mysql8 environment with Docker (with initial data) (your own memo)
I tried to build the environment of PlantUML Server with Docker
How to build [TypeScript + Vue + Express + MySQL] environment with Docker ~ MySQL edition ~
Build a development environment for Django + MySQL + nginx with Docker Compose
How to build [TypeScript + Vue + Express + MySQL] environment with Docker ~ Sequelize ~
Alert slack with alert manager in Docker environment
GPU environment construction with Docker [October 2020 version]
Rails environment construction with Docker (personal apocalypse)
Laravel development environment construction with Docker (Mac)
Build and manage RStudio environment with Docker-compose
Create Rails 6 + MySQL environment with Docker compose
Environment construction with Docker (Ubuntu20.04) + Laravel + nginx
Edit Mysql with commands in Docker environment
Create a MySQL environment with Docker from 0-> 1
Laravel + MySQL + phpMyadmin environment construction with Docker
Build Redmine code reading environment on Docker
Build Cakephp environment from docker installation Ubuntu
Build Nuxt TypeScript + Vuetify environment with docker-compose
Build an Ultra96v2 development environment on Docker 1
Lightweight PHP 7.4 development environment created with Docker