[英]using webshot inside a docker container
我嘗試使用webshot
(和phantomjs )內的一個碼頭工人的容器
請看看這個最小的Dockerfile
FROM rocker/geospatial
RUN R -e 'webshot::install_phantomjs()'
RUN apt-get update -qq && apt-get install -qy \
ca-certificates \
bzip2 \
curl \
libfontconfig \
--no-install-recommends \
&& curl -SL https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 > phantom.tar.bz2 \
&& bzip2 -d ./phantom.tar.bz2 \
&& tar -xvf ./phantom.tar -C /usr/local/ --strip-components=1 \
&& rm phantom.tar \
&& apt-get -qy remove bzip2 curl \
&& rm -rf /var/lib/apt/lists/*
然后
docker build . -t test
docker run -it test bash
在R
里面
webshot:::find_phantom() #"/usr/local/bin/phantomjs"
system("ping www.r-project.org") # ok
webshot::webshot("https://www.r-project.org/", "r.png") # nothing happend
知道為什么嗎?
謝謝
這可能是因為默認情況下,您位於發行版的根目錄,無法在其上書寫。
如果我嘗試這樣做:
~$ docker run -it rocker/geospatial bash
~$ R
> webshot::install_phantomjs()
> webshot:::find_phantom()
[1]“ / root / bin / phantomjs”
> list.files() # At the root /
> setwd("/home/rstudio/kitematic/") # Go to allowed directory
> webshot::webshot("https://www.r-project.org/", "r.png")
> list.files()
[1]“ r.png”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.