title: Docker Laravel Mysql: could not find driver
body: <p>When I run <code>docker-compose up</code> and do some <code>composer</code> commands, I get error</p>
  
  <blockquote>
    <p>In Connection.php line 664: could not find driver (SQL: select <code>id</code>, <code>name</code> from <code>users</code>  In Connector.php line 68: could not find driver ...</p>
  </blockquote>
  
  <p>Why cant Laravel connect to mysql? I can do <code>mysql -h db</code> in <code>docker-compose exec web bash</code> and it works. </p>
  
  <p>My setup</p>
  
  <p><code>docker-compose.yml</code></p>
  
  <pre><code>version: '3'
  
  services:
    web:
      build: ./webserver
      ports:
        - "80:80"
        - "443:443"
      volumes:
        - //docker/dockertest/webserver/app:/var/www/vhosts/app
      links:
        - db
      command:
         - /usr/local/bin/apache2_install_composer_dependencies.sh
  
    db:
      image: mysql:8.0
      container_name: db
      ports:
        - "3306:3306"
      command: --default-authentication-plugin=mysql_native_password
      environment:
        MYSQL_DATABASE: myDb
        MYSQL_USER: user
        MYSQL_PASSWORD: test
        MYSQL_ROOT_PASSWORD: test
      volumes:
        - //docker/dockertest/install/db_dump:/docker-entrypoint-initdb.d
        - persistent:/var/lib/mysql
      networks:
        - default
  
    phpmyadmin:
      image: phpmyadmin/phpmyadmin
      links:
        - db:db
      ports:
        - 8000:80
      environment:
        MYSQL_USER: user
        MYSQL_PASSWORD: test
        MYSQL_ROOT_PASSWORD: test
  
  
  
  volumes:
    persistent:
  </code></pre>
  
  <p>Laravel <code>.env</code> (I reference these values in <code>config/database.php</code>)</p>
  
  <pre><code>...
  DB_CONNECTION=mysql
  #host points to Docker container
  DB_HOST=db
  DB_PORT=3306
  DB_DATABASE=myDb
  DB_USERNAME=user
  DB_PASSWORD=test
  ....
  </code></pre>
  
  <p><code>webserver/Dockerfile</code></p>
  
  <pre><code>FROM php:7.2.19-apache-stretch
  
  # Configure Apache server
  COPY config_apache/sites-available /etc/apache2/sites-available
  
  # Create symlink in sites-enabled
  WORKDIR /etc/apache2/sites-enabled
  RUN ln -s /etc/apache2/sites-available/app.conf app.conf
  
  RUN mkdir -p /var/www/vhosts/app/logs
  
  COPY /build_files/install_composer_dependencies.sh /usr/local/bin/apache2_install_composer_dependencies.sh
  
  RUN apt-get update -y &amp;&amp; apt-get install -y  curl nano libapache2-mod-geoip git zip unzip mysql-client
  
  # Install Composer
  RUN curl -o /tmp/composer-setup.php https://getcomposer.org/installer \
  &amp;&amp; curl -o /tmp/composer-setup.sig https://composer.github.io/installer.sig \
  # Verify installer
  &amp;&amp; php -r "if (hash('SHA384', file_get_contents('/tmp/composer-setup.php')) !== trim(file_get_contents('/tmp/composer-setup.sig'))) { unlink('/tmp/composer-setup.php'); echo 'Invalid installer' . PHP_EOL; exit(1); }" \
  &amp;&amp; php /tmp/composer-setup.php --no-ansi --install-dir=/usr/local/bin --filename=composer --snapshot \
  &amp;&amp; rm -f /tmp/composer-setup.*
  
  RUN a2enmod rewrite
  RUN a2enmod geoip
  RUN service apache2 restart
  </code></pre>