title: Docker-compose + Dockerfile + Selenium Chrome Driver = unknown error: DevToolsActivePort file doesn't exist
body: <p>Good Morning Everyone!</p>
  
  <p><strong><em>Current scenery</em></strong><br>
  I've createad an API that uses selenium(Chrome-driver) to get data from a specific website and save it into a database. I've been trying to create a Docker that make it for me. The selenium script is running perfectly outside of Docker. </p>
  
  <p><strong><em>Dockerinzing</em></strong></p>
  
  <p>Because I need to connect in a Mysql database (to get data to search in api) and connect to Postgresql (to insert data that I received from selenium), I created a docker-compose to connect to them.  </p>
  
  <p>This is my docker-compose configuration:  </p>
  
  <pre><code>version: '2'
  services:
    postgres:
      image: postgres:9.3
      volumes: 
        - ./data/postgres:/var/lib/postgresql/data  
      restart: always
      ports: 
        - "5432:5432"
      environment:
        POSTGRES_DB: db
        POSTGRES_USER: user
        POSTGRES_PASSWORD: pass
    mysql:
      image: mysql:5.7
      volumes: 
        - /home/user/db/mysql/data:/var/lib/mysql
        - /home/user/db/mysql/init:/docker-entrypoint-initdb.d/:ro
      restart: always
      environment:
        MYSQL_ROOT_PASSWORD: passroot
        MYSQL_USER: user
        MYSQL_HOST: host
        MYSQL_PASSWORD: pass
        MYSQL_DATABASE: db
      ports: 
        - "3307:3306"
    web:
      build: .
      ports: 
        - "8080:8080"
  </code></pre>
  
  <p>and to create Docker, I created the Dockerfile below:</p>
  
  <pre><code>FROM ubuntu:18.04
  
  COPY pom.xml /usr/local/service/pom.xml
  COPY src /usr/local/service/src
  
  # Install required dependencies
  RUN apt-get update
  RUN apt-get install -y wget unzip curl dpkg
  
  #Install Open JDK 8
  RUN apt-get -y install software-properties-common
  RUN add-apt-repository -y ppa:openjdk-r/ppa
  RUN apt-get update
  RUN apt-get -y install openjdk-8-jdk
  
  # Install Chrome for Selenium
  RUN curl https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -o /chrome.deb
  RUN dpkg -i /chrome.deb || apt-get install -yf
  RUN rm /chrome.deb
  
  # Install chromedriver for Selenium
  RUN curl https://chromedriver.storage.googleapis.com/2.31/chromedriver_linux64.zip -o /usr/local/bin/chromedriver
  RUN chmod +x /usr/local/bin/chromedriver
  
  # Setup JAVA_HOME, this is useful for docker commandline
  ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
  ENV PATH $JAVA_HOME/bin:$PATH
  
  # Install Maven 
  RUN java -version &amp;&amp; ls -l /usr/bin/java    
  RUN apt-get update -y &amp;&amp; apt-get install maven -y
  RUN java -version &amp;&amp; ls -l /usr/bin/java  
  
  WORKDIR .
  COPY pom.xml /tmp/
  COPY src /tmp/src/
  WORKDIR /tmp/
  RUN mvn package
  
  WORKDIR .
  
  RUN cp -a target/*.jar /app.jar
  
  EXPOSE 8080
  
  ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
  </code></pre>
  
  <p>The docker-compose is build and run normally, but when I do a request in my api, I received the following message error:</p>
  
  <pre><code>{
      "timestamp": "2019-04-24T12:36:19.023+0000",
      "status": "500 INTERNAL_SERVER_ERROR",
      "mensagem": "unknown error: Chrome failed to start: exited abnormally\n  (unknown error: DevToolsActivePort file doesn't exist)\n  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)\n  (Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Linux 4.4.0-131-generic x86_64) (WARNING: The server did not provide any stacktrace information)\nCommand duration or timeout: 1.47 seconds\nBuild info: version: 'unknown', revision: 'unknown', time: 'unknown'\nSystem info: host: '41cd92b21873', ip: '172.18.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-131-generic', java.version: '1.8.0_191'\nDriver info: driver.version: ChromeDriver"
  }
  </code></pre>
  
  <p>I tried many others Chrome's and Chrome-driver's versions, but it's not work.</p>
  
  <p>I've searched in many others forums and they suggested me the following configuration(I had already used chrome headless configuration):  </p>
  
  <pre><code>        ChromeOptions options = new ChromeOptions();
          options.addArguments("--headless");
          options.addArguments("--no-sandbox");
          options.addArguments("--disable-dev-shm-usage");
          options.addArguments("--disable-extensions");
          options.addArguments("--disable-gpu");
          options.addArguments("disable-infobars");
  </code></pre>
  
  <p>But it's not working for me!</p>
  
  <p>Someone can help me to solve this or suggest me to do something better?</p>
  
  <p>Thanks a lot!</p>