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"]
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