【问题标题】:google app engine flexible with docker 'site cannot be reached'谷歌应用引擎灵活与 docker '站点无法访问'
【发布时间】:2019-08-31 05:43:56
【问题描述】:

我想使用 App Engine 为 R 模型提供服务器。 我正在关注这个例子R with app engine,但卡住了。我尝试了几种方法,但仍然有问题。关于这个问题的任何指导?

请参考我的代码 app.yaml

runtime: custom
env: flex

Dockerfile

FROM gcr.io/gcer-public/plumber-appengine
LABEL maintainer="mark"

RUN R -e "install.packages(c('plumber'), repos='http://cran.rstudio.com/')"

WORKDIR /payload/
COPY [".", "./"]

EXPOSE 8080
ENTRYPOINT ["R", "-e", "pr <- plumber::plumb(commandArgs()[4]); pr$run(host='0.0.0.0', port=8080)"]
CMD ["schedule.R"]

schedule.R

#* @get /demoR
get_predict_length <- function(){

  dataset <- iris

  # create the model
  model <- lm(Petal.Length ~ Petal.Width, data = dataset)
  petal_width = "0.4"

  #petal_width = '0.4'
  # convert the input to a number
  petal_width <- as.numeric(petal_width)

  #create the prediction data frame
  prediction_data <- data.frame(Petal.Width=petal_width)

  # create the prediction
  predict(model,prediction_data)
}

我使用'gcloud app deploy 进行部署并且成功了。我得到一个链接“https://iris-custom-dot-my-project-name.appspot.com/”。

日志中的最终输出

Stackdriver 日志显示:

  Starting server to listen on port 8080   

当我点击应用引擎版本 https://iris-custom-dot-my-project-name.appspot.com/' 时,我收到以下消息:

无法访问此网站

【问题讨论】:

    标签: r docker google-app-engine app-engine-flexible plumber


    【解决方案1】:

    办公网络问题

    就我而言,真正的问题是,我的办公室网络阻塞了端口 8080,所以当我在家中或办公室通过移动热点连接时,它可以正常工作。

    一般按照以下步骤解决问题。

    1) 搜索谷歌“我的公共 IP 地址”

    2) 在防火墙规则中添加您的 IP 将解决此问题。

    要么使用 gcloud 命令

    https://cloud.google.com/sdk/gcloud/reference/app/firewall-rules/create

    使用 GCP UI(您可以使用任何尚未使用的优先级编号)

    【讨论】:

      猜你喜欢
      • 2016-08-01
      • 2017-10-22
      • 2019-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-24
      • 2011-08-03
      相关资源
      最近更新 更多