分析脚本搭建docker环境:python, R

1. 搭建Anaconda Python3.6

FROM nvidia/cuda:8.0-cudnn6-devel-ubuntu16.04
MAINTAINER Tyan <tyan.liu.git@gmail.com>


# Install basic dependencies
RUN apt-get update && apt-get install -y --no-install-recommends 
        build-essential 
        cmake 
        git 
        wget 
        libopencv-dev 
        libsnappy-dev 
        python-dev 
        python-pip 
        tzdata 
        vim


# Install anaconda for python 3.6
RUN wget --quiet https://repo.continuum.io/archive/Anaconda3-5.0.1-Linux-x86_64.sh -O ~/anaconda.sh && 
    /bin/bash ~/anaconda.sh -b -p /opt/conda && 
    rm ~/anaconda.sh && 
    echo "export PATH=/opt/conda/bin:$PATH" >> ~/.bashrc


# Set timezone
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime


# Set locale
ENV LANG C.UTF-8 LC_ALL=C.UTF-8


# Initialize workspace
RUN mkdir /workspace
WORKDIR /workspace

2. dockerfile 安装python包

COPY requirements.txt /tmp/
RUN pip install --requirement /tmp/requirements.txt
COPY . /tmp/

3. 搭建R环境

FROM r-base


# 安装包
RUN R -e "install.packages('remotes'); 
remotes::install_version('tidystringdist', '0.1.2')"

RUN mkdir /home/analysis
COPY myscript.R /home/analysis/myscript.R

# 运行
CMD cd /home/analysis 
&& R -e "source('myscript.R')" 
&& mv /home/analysis/p.csv /home/results/p.csv

 已有R的docker image:  https://github.com/rocker-org/rocker

原文地址:https://www.cnblogs.com/snow-backup/p/11468705.html