首页 文章

托管VM添加到PATH

提问于
浏览
1

Google App Engine's Python runtime for Managed VMS,我想安装Splinter(selenium)Chromedriver . 根据Linux的文档,我在dockerfile中有以下内容:

# Dockerfile extending the generic Python image with application files for a
# single application.
FROM gcr.io/google_appengine/python-compat

RUN apt-get update && apt-get install -y apt-utils zip unzip wget

ADD requirements.txt /app/
RUN pip install -r requirements.txt

RUN cd $HOME/
RUN wget https://chromedriver.googlecode.com/files/chromedriver_linux64_20.0.1133.0.zip
RUN unzip chromedriver_linux64_20.0.1133.0.zip

RUN mkdir -p $HOME/bin
RUN mv chromedriver /bin
ENV PATH "$PATH:$HOME/bin"

ADD . /app

我无法让Web应用程序使用chrome webdriver启动Splinter,因为它在PATH中找不到它 .

WebDriverException:消息:'chromedriver'可执行文件需要在路径中可用 . 请查看http://docs.seleniumhq.org/download/#thirdPartyDrivers并阅读http://code.google.com/p/selenium/wiki/ChromeDriver

如果我按预期运行 docker exec -it <container id> chromedriver ,它就不起作用 .

此外,在Python中打印的环境变量是:

➜  ~  docker exec -it f4d9541c4ba6 python
Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> print os.environ
{'GAE_MODULE_NAME': 'parsers', 'API_HOST': '10.0.2.2', 'GAE_SERVER_PORT': '8082', 'MODULE_YAML_PATH': 'parsers.yaml', 'HOSTNAME': 'f4d9541c4ba6', 'SERVER_SOFTWARE': 'Development/2.0', 'GAE_MODULE_INSTANCE': '0', 'DEBIAN_FRONTEND': 'noninteractive', 'GAE_MINOR_VERSION': '580029170989395749', 'API_PORT': '59768', 'GAE_PARTITION': 'dev', 'GAE_LONG_APP_ID': 'utix-app', 'PATH': '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'GAE_MODULE_VERSION': 'parsers-0-0-1', 'HOME': '/root'}

将chromedriver置于PATH或任何解决方法的正确方法是什么?

非常感谢

1 回答

  • 0

    您需要检查与该图像关联的 ENTRYPOINTCMD (在您启动的容器上执行 docker inspect

    如果图像设置为打开新的bash会话,则与运行该会话的帐户关联的 profile 或_2788723可能会重新定义 $PATH ,从而覆盖Dockerfile ENV PATH "$PATH:$HOME/bin" 指令 .

    如果是这种情况,请确保 profile.bashrc 定义正确 PATH 更容易(例如 COPY 的自定义 .bashrc )修改 ENV .

相关问题