我正在将 Tensorflow Serving 容器部署到 Heroku,一切正常,但是当我尝试 ssh 到容器中执行某些命令时,Heroku 返回此错误:
C:\Users\whitm\Desktop\CodeProjects\deep-deblurring-serving>heroku ps:exec
Establishing credentials... error
! Could not connect to dyno!
! Check if the dyno is running with `heroku ps'
Dyno 运行正常:
C:\Users\whitm\Desktop\CodeProjects\deep-deblurring-serving>heroku ps
Free dyno hours quota remaining this month: 550h 0m (100%)
Free dyno usage for this app: 0h 0m (0%)
For more information on dyno sleeping and how to upgrade, see:
https://devcenter.heroku.com/articles/dyno-sleeping
=== web (Free): /bin/sh -c bash\ heroku-exec.sh (1)
web.1: up 2020/04/11 19:13:51 -0400 (~ 38s ago)
我发现了两年前的一个 StackOverflow 问题:Shell 进入在 Heroku dyno 上运行的 Docker 容器。如何? https://stackoverflow.com/questions/46652928/shell-into-a-docker-container-running-on-a-heroku-dyno-how。我已经处理了该问题解释的所有细节,以及有关此特定情况的 Heroku 官方文档:https://devcenter.heroku.com/articles/exec#using-with-docker https://devcenter.heroku.com/articles/exec#using-with-docker,但我无法使其发挥作用。
这是我的 Dockerfile:
FROM tensorflow/serving
LABEL maintainer="Whitman Bohorquez" description="Build tf serving based image. This repo must be used as build context"
COPY / /
RUN apt-get update \
&& apt-get install -y git \
&& git reset --hard \
&& apt-get install -y curl \
&& apt-get install -y openssh-server
ENV MODEL_NAME=deblurrer
# Updates listening ports
RUN echo '#!/bin/bash \n\n\
tensorflow_model_server \
--rest_api_port=$PORT \
--model_name=${MODEL_NAME} \
--model_base_path=/models/${MODEL_NAME} \
"$@"' > /usr/bin/tf_serving_entrypoint.sh \
&& chmod +x /usr/bin/tf_serving_entrypoint.sh
# Setup symbolic link from sh to bash
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
CMD bash heroku-exec.sh
一线特殊照顾RUN rm /bin/sh && ln -s /bin/bash /bin/sh
。我已经在容器中安装了 Curl、OpenSSH、Python。我创建文件heroku-exec.sh
with [ -z "$SSH_CLIENT" ] && source <(curl --fail --retry 3 -sSL "$HEROKU_EXEC_URL")
里面,并成功复制到/app/.profile.d
文件夹,即文件的最终路径为/app/.profile.d/heroku-exec.sh
。包容性我尝试执行最后一步,就好像容器位于 Heroku 私人空间中一样(事实并非如此),但我将删除它。
不知道还能尝试什么,希望有帮助,我觉得我做错了什么heroku-exec.sh
文件,但你怎么想?
提前致谢!