Building a Docker working environment for R and Python

Premise

Building docker environment with WSL

Dockerfile

Place the following code in your local working directory with the name "Dockerfile".

FROM ubuntu:18.04

 set timezone
RUN apt-get update \
    && apt-get install tzdata \
    && ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
RUN date

 install packages
RUN ["/bin/bash", "-c", "\
    apt-get update \
    && apt-get install -y \
    vim \
    build-essential \
    git curl llvm sqlite3 libssl-dev libbz2-dev \
    libreadline-dev libsqlite3-dev libncurses5-dev \
    libncursesw5-dev python-tk python3-tk tk-dev aria2 \
    lsb-release \
    python3.8 python3-pip \
    "]

 install pip package
RUN pip3 install pip --upgrade
RUN pip3 install pipenv
RUN python3 --version

RUN ["/bin/bash", "-c", "apt-get install -y software-properties-common"]
RUN apt-add-repository ppa:ansible/ansible -y
 install r
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
RUN add-apt-repository 'deb https://cran.rstudio.com/bin/linux/ubuntu $(lsb_release -cs)-cran35/'
RUN add-apt-repository 'deb https://cran.rstudio.com/bin/linux/ubuntu bionic-cran35/'
RUN ["/bin/bash", "-c", "\
    apt-get update \
    && apt-get install -y r-base \
    "]
RUN Rscript --version
CMD ["/bin/bash", "-c"]

Build and run

Place the following shell script in the directory where the Dockerfile is located.

!/bin/bash

step1="" # build
step2=do # run

 CONTAINER = favorite container name
 TAG = favorite tag name
NAME=${CONTAINER}:${TAG}

if [ $step1 ]; then
    sudo docker build -t $NAME .
fi

if [ $step2 ] ; then
    sudo docker run -itv `pwd`:/mnt/work $NAME /bin/bash
fi

If step1 = do, the build will be executed and Set step2 = do to start the container.

Specify your favorite container name in CONTAINER and your favorite tag name in TAG.

You can run the shell with the following command: (The shell script is hoge.sh)

chmod u+x hoge.sh
./hoge.sh

Recommended Posts

Building a Docker working environment for R and Python
Building a Docker working environment for R and Python 2: Japanese support
[Mac] Building a virtual environment for Python
Building a Python development environment for AI development
Building a python environment with virtualenv and direnv
Building a Python virtual environment
Building a Python virtual environment
Building a Python environment for pyenv, pyenv-virtualenv, Anaconda (Miniconda)
Write about building a Python environment for writing Qiita Qiita
Building and enabling a python virtual environment, etc. (venv)
Procedure for building a CDK environment on Windows (Python)
Building a Python environment for programming beginners (Mac OS)
Memo for building a machine learning environment using Python
Building a Python environment on Mac
Building a Python environment on Ubuntu
Building a virtual environment with Python 3
Building a python environment for artificial intelligence (Chainer / TensorFlow / CSLAIER)
Building a Python environment on a Mac and using Jupyter lab
Building a development environment for Android apps-creating Android apps in Python
Building a Hy environment for Lisper who hasn't touched Python
[Python] Building a virtual python environment for the pyramid tutorial (summary)
Building a Python3 environment with Amazon Linux2
Build and test a CI environment for multiple versions of Python
How about Anaconda for building a machine learning environment in Python?
Building a Windows 7 environment for getting started with machine learning with Python
Let's create a virtual environment for Python
From building a Python environment for inexperienced people to Hello world
Building a Python 3.6 environment with Windows + PowerShell
Building a conda environment for ROS users
Create a C ++ and Python execution environment with WSL2 + Docker + VSCode
Create a simple Python development environment with VS Code and Docker
[DynamoDB] [Docker] Build a development environment for DynamoDB and Django with docker-compose
LaTeX and R (a little Python) environment construction with SublimeText3 (Windows)
Building a virtual environment for Mayavi dedicated to Python 3.6, Anaconda, Spyder users
Quickly build a python environment for deep learning and data science (Windows)
Building an environment for executing Python scripts (for mac)
Building an Anaconda environment for Python with pyenv
Building a Python environment with WLS2 + Anaconda + PyCharm
ffmpeg-Build a python environment and split the video
[Python] Build a Django development environment with Docker
[Python] Web development preparation (building a virtual environment)
Pillow environment construction --For Docker + iPython (and OpenCV)
Think about building a Python 3 environment in a Mac environment
Commands for creating a python3 environment with virtualenv
Procedure for creating a Python quarantine environment (venv environment)
A memo for creating a python environment by a beginner
Building a Python environment on a Sakura VPS server
Build PyPy and Python execution environment with Docker
[Docker] Create a jupyterLab (python) environment in 3 minutes!
Create a Python environment
Python environment for projects
Build a Python + bottle + MySQL environment with Docker on RaspberryPi3! [Trial and error]
Build a local development environment with WSL + Docker Desktop for Windows + docker-lambda + Python
Python: Creating a virtual environment (venv), starting and stopping
Recommendation of building a portable Python environment with conda
Build a python virtual environment with virtualenv and virtualenvwrapper
Building a training environment for penetration testing using Naumachia
Build a python environment for each directory with pyenv-virtualenv
How to build a Django (python) environment on docker
Building an environment for natural language processing with Python
Build a python virtual environment with virtualenv and virtualenvwrapper