2015-04-21 88 views
1

Google App Engine's Python runtime for Managed VMS,我想安裝Splinter(硒)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 

,因爲它沒有在PATH找到它,我不能讓Web應用程序開始與鍍鉻的webdriver分裂。

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,或任何解決方法的正確方法?

非常感謝

回答

0

您需要檢查ENTRYPOINT並與圖像(你啓動的容器上的docker inspect

如果圖像設置爲打開一個新的bash會話相關CMD,該與運行該會話的帳戶關聯的profile.bashrc可能會重新定義$PATH,覆蓋Dockerfile ENV PATH "$PATH:$HOME/bin"指令。

如果是這樣的情況下,確保profile.bashrc定義權PATH更容易(與例如自定義.bashrcCOPY),修改了ENV

+0

檢查給 「CMD」:空, 「Entrpypoint」: 「/usr/bin/python2.7」, 「/home/vmagent/python_vm_runtime/vmboot.py」] 我相信這是它的情況被覆蓋。我將如何去做配置文件複製?對不起,我是新來的碼頭:) –

+0

@MichaelGradek首先,嘗試打印容器python會話(http://stackoverflow.com/a/4907053/6309)中的環境變量,以查看PATH是繼承的還是不。 – VonC

+0

看一下http://googleappengine.googlecode.com/svn/trunk/python/wrapper_util.py,看起來'GAE_SDK_ROOT'也應該被定義爲:你可以將它添加到Dockerfile中嗎? – VonC