How to bind-mount a browser(chrome) to a docker container

Viewed 53

I try to bind-mount a chrome browser to a docker container. But i'm getting error.

This is the message about the problem i'm facing.

OpenQA.Selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally.
  (chrome not reachable)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

My docker-compose is

version: "3.3"
services:
  myimage:
    image: mydockerhub.com/myimage
    environment:
      ASPNETCORE_ENVIRONMENT: "Development"
      AUTO_PROXY: "TRUE"
      DRIVER_PATH: "/usr/bin"
      BROWSER_HEADLESS: "TRUE"
      BROWSER_PATH: "/usr/bin/google-chrome"
    ports:
      - '30040:80'
    volumes:
      - type: bind
        source: /usr/bin/chromedriver
        target: /usr/bin/chromedriver
      - type: bind
        source: /usr/lib/
        target: /usr/lib/
      - type: bind
        source: /usr/bin/google-chrome
        target: /usr/bin/google-chrome
      - type: bind
        source: /usr/share/man/man1/google-chrome.1.gz
        target: /usr/share/man/man1/google-chrome.1.gz

My chromedriver version is equal to google-chrome version.

Versions are 105.0.5195.52 and same in both these versions.

I think my docker container is not find local google-chrome because when i type google-chrome --version terminal send a message to me as /usr/bin/google-chrome: line 49: /usr/bin/chrome: No such file or directory. But when i type google-chrome --version in out of docker container, i get Google Chrome 105.0.5195.52 result.

I think if i bind reference google-chrome to my docker container this problem will be solved.

I don't want to add chromedriver and google-chrome to my image because it will be very costly and my Image size will increase. Why am I increasing my image size if I can use google-chrome and chromedriver outside of the docker container?

How can i solve this problem ?

0 Answers
Related