docker安装rstudios


docker安装rstudios
docker exec --privileged -u root -it 容器id sh  以管理员方式访问容器

1、docker run -d -p 8787:8787  -p 6311:6311 quantumobject/docker-rstudio

2、docker exec -it container-id /bin/bash

        adduser mwlr1234

        passwd 1234

        mkdir /home/mwlr

        chmod -R 777 /home/mwlr1234

        sudo apt-get install default-jdk

         vi /etc/profile

                   export JAVA_HOME=/usr/lib/jvm/default-java

                   export JRE_HOME=${JAVA_HOME}/jre

                   export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib

                   export PATH=${JAVA_HOME}/bin:$PATH


3、登陆网址+端口号8787


install.packages(rJava)

install.packages(Rserve)

library(rJava)

library(Rserve)

4、rserve启动远程服务。默认rserve 未启动远程调用

#加载Rserver

> library("Rserve", lib.loc="~/R/x86_64-pc-linux-gnu-library/3.4")

#设置工作目录

> setwd("/R")

启动Rserver,web模式会错误

> Rserve()

 启动Rserver,web模式使用

> Rserve(args='--no-save')

Rserve(args="--no-save")  rstudio中启动rserve服务  cmd模式可以不要参数



 

  • Rserv.conf: 配置文件
  • source.R:初始化脚步文件

查看当前的Rserve 服务器的默认配置信息

  1.  
     
  2.  
    ~ R CMD Rserve --RS-settings
  3.  
    Rserve v1.7-1
  4.  
     
  5.  
    config file: /etc/Rserv.conf
  6.  
    working root: /tmp/Rserv
  7.  
    port: 6311
  8.  
    local socket: [none, TCP/IP used]
  9.  
    authorization required: no
  10.  
    plain text password: not allowed
  11.  
    passwords file: [none]
  12.  
    allow I/O: yes
  13.  
    allow remote access: no
  14.  
    control commands: no
  15.  
    interactive: yes
  16.  
    max.input buffer size: 262144 kB
  • config file: 我本地无此文件/etc/Rserv.conf, 系统会默认跳过这项
  • working root: R运行时工作目录 /tmp/Rserv
  • port: 通信端口6311
  • local socket: TCP/IP协议
  • authorization: 认证未开启
  • plain text password: 不允许明文密码
  • passwords file: 密码文件,未指定
  • allow I/O: 允许IO操作
  • allow remote access: 远程访问未开启
  • control commands: 命令控制未开启
  • interactive: 允许通信
  • max.input buffer size: 文件上传限制262mb

修改默认配置,新建文件:/etc/Rserv.conf

  1.  
     
  2.  
    ~ sudo vi /etc/Rserv.conf
  3.  
     
  4.  
    workdir /tmp/Rserv
  5.  
    remote enable
  6.  
    fileio enable
  7.  
    interactive yes
  8.  
    port 6311
  9.  
    maxinbuf 262144
  10.  
    encoding utf8
  11.  
    control enable
  12.  
    source /home/conan/R/RServe/source.R
  13.  
    eval xx=1
  14.  
     
  15.  
    ~ vi /home/conan/R/RServe/source.R
  16.  
     
  17.  
    cat("This is my Rserve!!")
  18.  
    print(paste("Server start at",Sys.time()))

再次查看服务器配置

  1.  
     
  2.  
    R CMD Rserve --RS-settings
  3.  
    Rserve v1.7-1
  4.  
     
  5.  
    config file: /etc/Rserv.conf
  6.  
    working root: /tmp/Rserv
  7.  
    port: 6311
  8.  
    local socket: [none, TCP/IP used]
  9.  
    authorization required: yes
  10.  
    plain text password: allowed
  11.  
    passwords file: [none]
  12.  
    allow I/O: yes
  13.  
    allow remote access: yes
  14.  
    control commands: yes
  15.  
    interactive: yes
  16.  
    max.input buffer size: 262144 kB
  • 允许远程访问
  • 需要登陆认证
  • 允许明文密码