1

In Google App Engine's Python runtime for Managed VMS, I want to install the Splinter (selenium) Chromedriver. According to the documentation for Linux, I have the following in my 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

I can't get the web application to start Splinter with the chrome webdriver as it does not find it in the PATH.

WebDriverException: Message: 'chromedriver' executable needs to be
available in the path. Please look at
http://docs.seleniumhq.org/download/#thirdPartyDrivers
and read up at
http://code.google.com/p/selenium/wiki/ChromeDriver

And if I run docker exec -it <container id> chromedriver, as expected, it doesn't work.

Also, the environment variables printed out in Python are:

➜  ~  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'}

What would be the correct way of making the chromedriver be in the PATH, or any workaround?

Thanks a lot

Michael Gradek
  • 2,628
  • 3
  • 29
  • 35

1 Answers1

0

You need to check the ENTRYPOINT and CMD associated with that image (do a docker inspect on the container you launched)

If the image is set to open a new bash session, the profile or .bashrc associated with the account running that session might redefine $PATH, overriding the Dockerfile ENV PATH "$PATH:$HOME/bin" directive.

If that is the case, making sure the profile or .bashrc defines the right PATH is easier (with a COPY of a custom .bashrc for instance) that modifying the ENV.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • inspect gives "Cmd": null, "Entrpypoint": ["/usr/bin/python2.7", "/home/vmagent/python_vm_runtime/vmboot.py"] I believe it is the case that it's being overriden. How would I go about to do the profile copy? Sorry, i'm new to docker :) – Michael Gradek Apr 21 '15 at 06:29
  • @MichaelGradek first, try and print the environment variables in your container python session (http://stackoverflow.com/a/4907053/6309), to see if the PATH was inherited or not. – VonC Apr 21 '15 at 06:40
  • Looking at http://googleappengine.googlecode.com/svn/trunk/python/wrapper_util.py, it seems `GAE_SDK_ROOT` should be defined as well: can you add it in the Dockerfile? – VonC Apr 21 '15 at 06:49
  • I've updated the question to show the available environment variables. When I try adding GAE_SDK_ROOT manually, either I don't know where the SDK lives in the container, or it simply no python scripts work when I point it to what looks like the SDK in Docker – Michael Gradek Apr 21 '15 at 16:53