【问题标题】:Setting active docker machine in R在 R 中设置活动的 docker 机器
【发布时间】:2019-11-17 14:10:23
【问题描述】:

我想以更专业的方式进行一些网页抓取。为此,我想启动一台 docker 机器并从 R 在其上运行 selenium 服务器。

我的代码:

shell("docker-machine create m1") # Creating docker machine (It is also visible in CMD manualy)

conf <- shell("docker-machine env m1", intern = T) # Geting the comands to set the machine "m1" active
conf <- conf[grepl("SET",conf)] # There was some REM functions so I removed it
for(i in 1:length(conf)){
  shell(conf[i]) # Activating each line of code separetly (They are only SET functions)
}

shell('docker-machine active')

问题是最后一个命令告诉我没有任何激活的机器......

我已经在 CMD 中手动输入了 docker-machine env m1 的每个命令,然后在 CMD 中有一台活动机器,但在 R 中没有。

【问题讨论】:

  • 嗨,Kamil,您能否分享更多信息以重现该问题?例如Dockerfile,如何启动/构建/运行,所需的任何依赖项。最好的情况是我可以在我的机器上重新创建问题并在那里调试。
  • 嗨 Clemens,我只下载并安装了 Docker Toolbox for Windows。然后我尽力了解 Docker 是如何工作的
  • 请分享您的错误日志
  • 为什么要使用 docker machine 而不是 windows 的 docker desktop?另外,你为什么要用 R 来写,而不是 bash 或 PowerShell?

标签: r docker docker-machine


【解决方案1】:

我可以用以下代码做到这一点:

library(RSelenium)
shell('docker run -d -p 4445:4444 selenium/standalone-firefox')
remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4445L, browserName = "firefox")
remDr$open()
remDr$navigate("https://www.google.com/")

【讨论】:

    猜你喜欢
    • 2019-07-27
    • 2019-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-17
    • 1970-01-01
    相关资源
    最近更新 更多