Heroku上部署Docker时出现错误 - 权限被拒绝。

3

我想使用Docker在Heroku上部署网页。我有两个入口点。

ENTRYPOINT ["/app/entrypoint.sh"]
ENTRYPOINT ["/app/yt_bot.py"]

第一个入口点工作得很好。

enter image description here

但是当它到达第二个入口点时,会抛出错误:“权限被拒绝”

enter image description here

这是 yt_bot.py 的代码:

from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://www.youtube.com/')

我已将Firefox Web驱动程序安装在usr/local/bin中。错误是否与此有关?

编辑

这是我的Dockerfile:

FROM debian:stretch
# Install git, supervisor, VNC, & X11 packages
RUN set -ex; \
    apt-get update; \
    apt -y install python-pip; \
    pip install selenium; \
    apt-get -y install wget; \
    wget https://github.com/mozilla/geckodriver/releases/download/v0.29.1/geckodriver-v0.29.1-linux64.tar.gz; \
    tar xvf geckodriver-v0.29.1-linux64.tar.gz; \
    mv geckodriver usr/local/bin; \
    rm geckodriver-v0.29.1-linux64.tar.gz; \
    export PATH=$PATH:/usr/local/bin/geckodriver; \
    wget https://download1320.mediafire.com/p27lunltbdqg/vu5daioshg687nx/yt_bot.py; \
    apt-get install -y \
      bash \
      fluxbox \
      git \
      net-tools \
      novnc \
      socat \
      supervisor \
      x11vnc \
      xterm \
      xvfb
ENV HOME=/root \
    DEBIAN_FRONTEND=noninteractive \
    LANG=en_US.UTF-8 \
    LANGUAGE=en_US.UTF-8 \
    LC_ALL=C.UTF-8 \
    DISPLAY=:0.0 \
    DISPLAY_WIDTH=1024 \
    DISPLAY_HEIGHT=768 \
    RUN_XTERM=yes \
    RUN_FLUXBOX=yes
COPY . /app
RUN chmod +x /app/conf.d/websockify.sh
ENTRYPOINT ["/app/entrypoint.sh"]
ENTRYPOINT ["/app/yt_bot.py"]

你是否在Docker容器内安装了webdriver?请分享你的Dockerfile。 - Beppe C
我现在已经添加了我的Dockerfile。 - Antonio Sanchez
你能在 app/yt_bot.py 上运行 chmod +x 命令,然后重新构建镜像吗?我猜 yt_bot.py 缺少可执行权限。 - akazuko
在 yt_bot.py 中运行 Chmod +x 解决了问题。谢谢! - Antonio Sanchez
1个回答

2

为了以root用户身份运行命令,请将以下行添加到您的Dockerfile中。

...
USER root # add this line before entry points
ENTRYPOINT ["/app/entrypoint.sh"]
ENTRYPOINT ["/app/yt_bot.py"]

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接