title: unknown error: DevToolsActivePort file doesn't exist when running in Docker
body: <p>I am trying to run chrome using Python and selenium in a Docker container running alpine. It was running fine until one day when it started throwing the following error when I instantiated chrome.</p>
  <pre class="lang-sh prettyprint-override"><code>Message: unknown error: Chrome failed to start: crashed.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/lib/chromium/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
  </code></pre>
  <h2>Code</h2>
  <p>Here is the code that creates this error:</p>
  <pre class="lang-py prettyprint-override"><code>from selenium import webdriver
  
  
  def generate_plugin():
      pluginfile = 'proxy_auth_plugin.zip'
  
      # manifest_json, background_js same as https://stackoverflow.com/a/61764363/9809865
  
      with zipfile.ZipFile(pluginfile, 'w') as zp:
          zp.writestr(&quot;manifest.json&quot;, manifest_json)
          zp.writestr(&quot;background.js&quot;, background_js)
      return pluginfile
  
  
  chrome_options = webdriver.ChromeOptions()
  prefs = {&quot;profile.default_content_setting_values.notifications&quot;: 2}
  chrome_options.add_experimental_option(&quot;prefs&quot;, prefs)
  plugin = generate_plugin()
  chrome_options.add_extension(plugin)
  chrome_options.add_argument('--no-sandbox')
  chrome_options.add_argument('--disable-dev-shm-usage')
  chrome_options.add_argument(&quot;--window-size=1920,1080&quot;)
  chrome_options.add_argument(&quot;--remote-debugging-port=9222&quot;)
  driver = webdriver.Chrome(chrome_options=chrome_options)
  driver.get(&quot;https://google.com&quot;)
  </code></pre>
  <p>The full traceback of the exception it generates</p>
  <h3>Full traceback</h3>
  <pre class="lang-sh prettyprint-override"><code>driver = webdriver.Chrome(chrome_options=chrome_options)
  |   File &quot;/usr/local/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py&quot;, line 81, in __init__
  |     desired_capabilities=desired_capabilities)
  |   File &quot;/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py&quot;, line 157, in __init__
  |     self.start_session(capabilities, browser_profile)
  |   File &quot;/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py&quot;, line 252, in start_session
  |     response = self.execute(Command.NEW_SESSION, parameters)
  |   File &quot;/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py&quot;, line 321, in execute
  |     self.error_handler.check_response(response)
  |   File &quot;/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py&quot;, line 242, in check_response
  |     raise exception_class(message, screen, stacktrace)
  
  Message: unknown error: Chrome failed to start: crashed.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/lib/chromium/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
  </code></pre>
  <p>I am using <code>pyvirtualdisplay</code> for the display for webdriver but even if I add the <code>--headless</code> option in my code, it throws the same error.</p>
  <h2>Dockerfile</h2>
  <p>This is my Dockerfile:</p>
  <pre><code>FROM python:3.6-alpine
  
  RUN apk add xvfb
  
  # update apk repo
  RUN echo &quot;http://dl-4.alpinelinux.org/alpine/v3.7/main&quot; &gt;&gt; /etc/apk/repositories &amp;&amp; \
      echo &quot;http://dl-4.alpinelinux.org/alpine/v3.7/community&quot; &gt;&gt; /etc/apk/repositories
  
  # install chromedriver
  RUN apk update
  RUN apk add chromium=93.0.4577.82-r2 --repository=http://dl-cdn.alpinelinux.org/alpine/v3.15/community chromium-chromedriver=93.0.4577.82-r2
  </code></pre>
  <pre class="lang-sh prettyprint-override"><code>/usr/lib/chromium # ./chrome --version
  Chromium 93.0.4577.82
  /usr/lib/chromium # ./chromedriver --version
  ChromeDriver 93.0.4577.82 (e3a25d9b9e2d0b728e045ec87c0aa4942aa46e4e-refs/branch-heads/4577@{#1237})
  /usr/lib/chromium #
  </code></pre>
  <h2>Original issue</h2>
  <p>I was originally using <code>RUN apk add chromium=86.0.4240.111-r0 --repository=http://dl-cdn.alpinelinux.org/alpine/v3.13/community chromium-chromedriver=86.0.4240.111-r0</code></p>
  <p>It had been running fine until it started throwing that exception. So I went to my docker container and tried to run Chrome manually. It threw this error</p>
  <pre class="lang-sh prettyprint-override"><code>Error relocating ./chrome: hb_subset_input_set_drop_hints: symbol not found
  Error relocating ./chrome: hb_subset_input_set_retain_gids: symbol not found
  Error relocating ./chrome: hb_subset: symbol not found
  </code></pre>
  <p>Once I upgraded the Chrome version to 93.0.4577.82, I can manually start both Chrome and Chromedriver, but running the code produces the same traceback.</p>
  <h2>OS and Docker version</h2>
  <p>I am using Macbook Pro M1 (2020) with MacOS 12.1</p>
  <p>Docker version is the latest: 4.3.2 (72729)</p>
  <h2>Things I have tried</h2>
  <p>I have looked at almost all the other questions asked on StackOverflow and other forums but none of the advices have worked for me till now.</p>
  <ul>
  <li><p>I tried all the Chrome and Chromedriver versions available on alpine from 72.0.3626.121-r0 to the edge version</p>
  </li>
  <li><p>I have even purged all the images, containers, and volumes from Docker and reinstalled it. It did not help either.</p>
  </li>
  </ul>
  <h3>Update:</h3>
  <p>Passing the <code>--headless</code> argument makes it run. This makes me assume that the issue is somewhere related to using <code>pyvirtualdisplay</code></p>
  <h4>Update 2</h4>
  <p>I missed to add that I was creating an extension zip file to add it to Chrome on the fly.</p>
  <p>Here is what's happening now:</p>
  <ol>
  <li>Pass the argument &quot;--headless&quot; and disable adding extension, it works completely fine.</li>
  <li>Pass the argument &quot;--headless&quot; and enable adding extension, it throws, understandably <code>selenium.common.exceptions.WebDriverException: Message: Message: unknown error: failed to wait for extension background page to load: chrome-extension://ilkejjjhcpjkcecgdkkdfaocminnclpo/_generated_background_page.html</code></li>
  <li>Don't pass the <code>--headless</code> argument and disable extension, it <strong>works completely fine</strong></li>
  <li>Don't pass the <code>--headless</code> argument and enable extension, it throws the same exception as in point 2.</li>
  </ol>