This is a rather strange situation that I encountered. I have the following simple Python script:
from selenium import webdriver from selenium.webdriver.firefox.options import Options options = Options() options.add_argument("-headless") browser = webdriver.Firefox(firefox_options=options) browser.get("https://www.google.com") print(browser.current_url)
And a wrapper for the script:
#!/bin/bash wget https://github.com/mozilla/geckodriver/releases/download/v0.19.1/geckodriver-v0.19.1-linux64.tar.gz tar -xzvf geckodriver-v0.19.1-linux64.tar.gz chmod 777 geckodriver mv geckodriver /usr/bin/ firefox -v
In addition, I have two Dockerfiles:
Dockerfile A (Ubuntu; works great):
FROM ubuntu:16.04 RUN apt-get update -y && apt-get install -y python3 \ python3-pip \ firefox \ build-essential \ wget COPY . /app WORKDIR /app RUN pip3 install
Dockerfile B (Debian; crashes):
FROM continuumio/anaconda3:5.0.1 RUN apt-get update -y && apt-get install -y iceweasel \ build-essential \ wget COPY . /app WORKDIR /app RUN pip install
test.py run from an image created from Dockerfile B throws the following exception:
selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status: 1
geckodriver.log shows the following error:
GTK_BACKEND doesn't match available displays
Has anyone come across this and knew a workaround? It should not need access to the display, because it works without a brain - unless selenium Firefox's parameters are different in iceweasel than regular Firefox? I expected similar behavior and I would rather use an Anaconda image
I just tried this one , which I would almost certainly allow, but it didn’t work.
EDIT . I don't think this is a geckodriver problem, as I tried to use the same Docker file with firefox-esr instead of iceweasel . Also, I tried to run the container interactively and firefox -headless (which on ubuntu starts a firefox headless session), it gave the exact same GTK serial message.