could not find driver error in lumen 5.6 app (running in docker + alpine linux + nginx + php-fpm 7.2)












1















I am trying to add database access to my Lumen 5.6 app, currently running in docker in the following LEMP Stack:




  • Alpine Linux

  • PHP-FPM 7.2.x

  • NGINX


My compose file looks like this:



version: '2.1'

services:

webhooks-mysql:
container_name: webhooks-mysql
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_DATABASE: webhooks
MYSQL_USER: webhooks
MYSQL_PASSWORD: 123456
healthcheck:
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
timeout: 20s
retries: 10
ports:
- "33401:3306"

webhooks-service:
container_name: webhooks-service
depends_on:
webhooks-mysql:
condition: service_healthy
build: .
mem_limit: 64M
ports:
- "9050:80"
volumes:
- ./:/app:cached


and I have the following in my .env:



APP_NAME=webhooks
APP_ENV=local
APP_DEBUG=true
APP_KEY=base64:123456=
APP_TIMEZONE=UTC

DB_CONNECTION=mysql
DB_HOST=webhooks-mysql
DB_DATABASE=webhooks
DB_USERNAME=webhooks
DB_PASSWORD=123456


and lastly; my container has all of the require dependencies:



php7 php7-fpm php7-mysqli php7-pdo php7-openssl php7-mbstring
php7-xml php7-tokenizer php7-json php7-openssl php7-curl php7-zlib
php7-xml php7-phar php7-intl php7-dom php7-xmlreader php7-ctype
php7-mbstring php7-gd php7-zip git nginx supervisor curl zip unzip


and the following composer packages:



  "require": {
"php": ">=7.1.3",
"laravel/lumen-framework": "5.6.*",
"vlucas/phpdotenv": "~2.2",
"wikimedia/ip-set": "^1.2",
"doctrine/dbal": "^2.8"
}


When I try to run the migration within the container, I am getting the following error:




/app # php artisan migrate



In Connection.php line 664:
could not find driver (SQL: select * from information_schema.tables
where table_schema = webhooks and table_name = )



In PDOConnection.php line 50:
could not find driver




Any ideas why I am getting this error?



I've already verified the php-mysql / pdo extensions are loaded, env values are correct etc... I can't seem to figure it out.










share|improve this question





























    1















    I am trying to add database access to my Lumen 5.6 app, currently running in docker in the following LEMP Stack:




    • Alpine Linux

    • PHP-FPM 7.2.x

    • NGINX


    My compose file looks like this:



    version: '2.1'

    services:

    webhooks-mysql:
    container_name: webhooks-mysql
    image: mysql:5.7
    restart: always
    environment:
    MYSQL_ROOT_PASSWORD: 123456
    MYSQL_DATABASE: webhooks
    MYSQL_USER: webhooks
    MYSQL_PASSWORD: 123456
    healthcheck:
    test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
    timeout: 20s
    retries: 10
    ports:
    - "33401:3306"

    webhooks-service:
    container_name: webhooks-service
    depends_on:
    webhooks-mysql:
    condition: service_healthy
    build: .
    mem_limit: 64M
    ports:
    - "9050:80"
    volumes:
    - ./:/app:cached


    and I have the following in my .env:



    APP_NAME=webhooks
    APP_ENV=local
    APP_DEBUG=true
    APP_KEY=base64:123456=
    APP_TIMEZONE=UTC

    DB_CONNECTION=mysql
    DB_HOST=webhooks-mysql
    DB_DATABASE=webhooks
    DB_USERNAME=webhooks
    DB_PASSWORD=123456


    and lastly; my container has all of the require dependencies:



    php7 php7-fpm php7-mysqli php7-pdo php7-openssl php7-mbstring
    php7-xml php7-tokenizer php7-json php7-openssl php7-curl php7-zlib
    php7-xml php7-phar php7-intl php7-dom php7-xmlreader php7-ctype
    php7-mbstring php7-gd php7-zip git nginx supervisor curl zip unzip


    and the following composer packages:



      "require": {
    "php": ">=7.1.3",
    "laravel/lumen-framework": "5.6.*",
    "vlucas/phpdotenv": "~2.2",
    "wikimedia/ip-set": "^1.2",
    "doctrine/dbal": "^2.8"
    }


    When I try to run the migration within the container, I am getting the following error:




    /app # php artisan migrate



    In Connection.php line 664:
    could not find driver (SQL: select * from information_schema.tables
    where table_schema = webhooks and table_name = )



    In PDOConnection.php line 50:
    could not find driver




    Any ideas why I am getting this error?



    I've already verified the php-mysql / pdo extensions are loaded, env values are correct etc... I can't seem to figure it out.










    share|improve this question



























      1












      1








      1








      I am trying to add database access to my Lumen 5.6 app, currently running in docker in the following LEMP Stack:




      • Alpine Linux

      • PHP-FPM 7.2.x

      • NGINX


      My compose file looks like this:



      version: '2.1'

      services:

      webhooks-mysql:
      container_name: webhooks-mysql
      image: mysql:5.7
      restart: always
      environment:
      MYSQL_ROOT_PASSWORD: 123456
      MYSQL_DATABASE: webhooks
      MYSQL_USER: webhooks
      MYSQL_PASSWORD: 123456
      healthcheck:
      test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
      timeout: 20s
      retries: 10
      ports:
      - "33401:3306"

      webhooks-service:
      container_name: webhooks-service
      depends_on:
      webhooks-mysql:
      condition: service_healthy
      build: .
      mem_limit: 64M
      ports:
      - "9050:80"
      volumes:
      - ./:/app:cached


      and I have the following in my .env:



      APP_NAME=webhooks
      APP_ENV=local
      APP_DEBUG=true
      APP_KEY=base64:123456=
      APP_TIMEZONE=UTC

      DB_CONNECTION=mysql
      DB_HOST=webhooks-mysql
      DB_DATABASE=webhooks
      DB_USERNAME=webhooks
      DB_PASSWORD=123456


      and lastly; my container has all of the require dependencies:



      php7 php7-fpm php7-mysqli php7-pdo php7-openssl php7-mbstring
      php7-xml php7-tokenizer php7-json php7-openssl php7-curl php7-zlib
      php7-xml php7-phar php7-intl php7-dom php7-xmlreader php7-ctype
      php7-mbstring php7-gd php7-zip git nginx supervisor curl zip unzip


      and the following composer packages:



        "require": {
      "php": ">=7.1.3",
      "laravel/lumen-framework": "5.6.*",
      "vlucas/phpdotenv": "~2.2",
      "wikimedia/ip-set": "^1.2",
      "doctrine/dbal": "^2.8"
      }


      When I try to run the migration within the container, I am getting the following error:




      /app # php artisan migrate



      In Connection.php line 664:
      could not find driver (SQL: select * from information_schema.tables
      where table_schema = webhooks and table_name = )



      In PDOConnection.php line 50:
      could not find driver




      Any ideas why I am getting this error?



      I've already verified the php-mysql / pdo extensions are loaded, env values are correct etc... I can't seem to figure it out.










      share|improve this question
















      I am trying to add database access to my Lumen 5.6 app, currently running in docker in the following LEMP Stack:




      • Alpine Linux

      • PHP-FPM 7.2.x

      • NGINX


      My compose file looks like this:



      version: '2.1'

      services:

      webhooks-mysql:
      container_name: webhooks-mysql
      image: mysql:5.7
      restart: always
      environment:
      MYSQL_ROOT_PASSWORD: 123456
      MYSQL_DATABASE: webhooks
      MYSQL_USER: webhooks
      MYSQL_PASSWORD: 123456
      healthcheck:
      test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
      timeout: 20s
      retries: 10
      ports:
      - "33401:3306"

      webhooks-service:
      container_name: webhooks-service
      depends_on:
      webhooks-mysql:
      condition: service_healthy
      build: .
      mem_limit: 64M
      ports:
      - "9050:80"
      volumes:
      - ./:/app:cached


      and I have the following in my .env:



      APP_NAME=webhooks
      APP_ENV=local
      APP_DEBUG=true
      APP_KEY=base64:123456=
      APP_TIMEZONE=UTC

      DB_CONNECTION=mysql
      DB_HOST=webhooks-mysql
      DB_DATABASE=webhooks
      DB_USERNAME=webhooks
      DB_PASSWORD=123456


      and lastly; my container has all of the require dependencies:



      php7 php7-fpm php7-mysqli php7-pdo php7-openssl php7-mbstring
      php7-xml php7-tokenizer php7-json php7-openssl php7-curl php7-zlib
      php7-xml php7-phar php7-intl php7-dom php7-xmlreader php7-ctype
      php7-mbstring php7-gd php7-zip git nginx supervisor curl zip unzip


      and the following composer packages:



        "require": {
      "php": ">=7.1.3",
      "laravel/lumen-framework": "5.6.*",
      "vlucas/phpdotenv": "~2.2",
      "wikimedia/ip-set": "^1.2",
      "doctrine/dbal": "^2.8"
      }


      When I try to run the migration within the container, I am getting the following error:




      /app # php artisan migrate



      In Connection.php line 664:
      could not find driver (SQL: select * from information_schema.tables
      where table_schema = webhooks and table_name = )



      In PDOConnection.php line 50:
      could not find driver




      Any ideas why I am getting this error?



      I've already verified the php-mysql / pdo extensions are loaded, env values are correct etc... I can't seem to figure it out.







      php docker migration lumen






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 28 '18 at 19:44







      Latheesan

















      asked Nov 28 '18 at 18:49









      LatheesanLatheesan

      12.5k1766130




      12.5k1766130
























          2 Answers
          2






          active

          oldest

          votes


















          0














          Since the docker image is completely stripped down there are more dependencies then you might expect, I encountered the same issue and fixed it by adding the extension pdo_mysql in addition to the ones you already have (pdo, mysqli and mbstring).






          share|improve this answer































            0














            I've fixed the issue by using the following Dockerfile:



            FROM php:7.2-fpm-alpine

            # Install packages
            RUN docker-php-ext-configure pdo_mysql && docker-php-ext-install pdo_mysql
            && apk add --update
            ca-certificates
            curl
            git
            zip
            unzip
            nano
            && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
            && rm -rf /var/cache/apk/*

            # Configure php-fpm
            COPY scripts/fpm-pool.conf /etc/php7/php-fpm.d/zzz_custom.conf
            COPY scripts/php.ini /usr/local/etc/php/conf.d/zzz_custom.ini

            # Add Application
            WORKDIR /app
            ADD . /app





            share|improve this answer
























            • This looks like the same solution as I suggested in my answer, might I ask why you post it as your own answer instead of accepting the solution?

              – Sven Hakvoort
              Nov 30 '18 at 11:21











            • Because I've shown how to properly do it for alpine & which command to use, i.e. docker-php-ext-configure pdo_mysql && docker-php-ext-install pdo_mysql .

              – Latheesan
              Nov 30 '18 at 11:39












            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53526168%2fcould-not-find-driver-error-in-lumen-5-6-app-running-in-docker-alpine-linux%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Since the docker image is completely stripped down there are more dependencies then you might expect, I encountered the same issue and fixed it by adding the extension pdo_mysql in addition to the ones you already have (pdo, mysqli and mbstring).






            share|improve this answer




























              0














              Since the docker image is completely stripped down there are more dependencies then you might expect, I encountered the same issue and fixed it by adding the extension pdo_mysql in addition to the ones you already have (pdo, mysqli and mbstring).






              share|improve this answer


























                0












                0








                0







                Since the docker image is completely stripped down there are more dependencies then you might expect, I encountered the same issue and fixed it by adding the extension pdo_mysql in addition to the ones you already have (pdo, mysqli and mbstring).






                share|improve this answer













                Since the docker image is completely stripped down there are more dependencies then you might expect, I encountered the same issue and fixed it by adding the extension pdo_mysql in addition to the ones you already have (pdo, mysqli and mbstring).







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 29 '18 at 7:04









                Sven HakvoortSven Hakvoort

                2,2102724




                2,2102724

























                    0














                    I've fixed the issue by using the following Dockerfile:



                    FROM php:7.2-fpm-alpine

                    # Install packages
                    RUN docker-php-ext-configure pdo_mysql && docker-php-ext-install pdo_mysql
                    && apk add --update
                    ca-certificates
                    curl
                    git
                    zip
                    unzip
                    nano
                    && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
                    && rm -rf /var/cache/apk/*

                    # Configure php-fpm
                    COPY scripts/fpm-pool.conf /etc/php7/php-fpm.d/zzz_custom.conf
                    COPY scripts/php.ini /usr/local/etc/php/conf.d/zzz_custom.ini

                    # Add Application
                    WORKDIR /app
                    ADD . /app





                    share|improve this answer
























                    • This looks like the same solution as I suggested in my answer, might I ask why you post it as your own answer instead of accepting the solution?

                      – Sven Hakvoort
                      Nov 30 '18 at 11:21











                    • Because I've shown how to properly do it for alpine & which command to use, i.e. docker-php-ext-configure pdo_mysql && docker-php-ext-install pdo_mysql .

                      – Latheesan
                      Nov 30 '18 at 11:39
















                    0














                    I've fixed the issue by using the following Dockerfile:



                    FROM php:7.2-fpm-alpine

                    # Install packages
                    RUN docker-php-ext-configure pdo_mysql && docker-php-ext-install pdo_mysql
                    && apk add --update
                    ca-certificates
                    curl
                    git
                    zip
                    unzip
                    nano
                    && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
                    && rm -rf /var/cache/apk/*

                    # Configure php-fpm
                    COPY scripts/fpm-pool.conf /etc/php7/php-fpm.d/zzz_custom.conf
                    COPY scripts/php.ini /usr/local/etc/php/conf.d/zzz_custom.ini

                    # Add Application
                    WORKDIR /app
                    ADD . /app





                    share|improve this answer
























                    • This looks like the same solution as I suggested in my answer, might I ask why you post it as your own answer instead of accepting the solution?

                      – Sven Hakvoort
                      Nov 30 '18 at 11:21











                    • Because I've shown how to properly do it for alpine & which command to use, i.e. docker-php-ext-configure pdo_mysql && docker-php-ext-install pdo_mysql .

                      – Latheesan
                      Nov 30 '18 at 11:39














                    0












                    0








                    0







                    I've fixed the issue by using the following Dockerfile:



                    FROM php:7.2-fpm-alpine

                    # Install packages
                    RUN docker-php-ext-configure pdo_mysql && docker-php-ext-install pdo_mysql
                    && apk add --update
                    ca-certificates
                    curl
                    git
                    zip
                    unzip
                    nano
                    && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
                    && rm -rf /var/cache/apk/*

                    # Configure php-fpm
                    COPY scripts/fpm-pool.conf /etc/php7/php-fpm.d/zzz_custom.conf
                    COPY scripts/php.ini /usr/local/etc/php/conf.d/zzz_custom.ini

                    # Add Application
                    WORKDIR /app
                    ADD . /app





                    share|improve this answer













                    I've fixed the issue by using the following Dockerfile:



                    FROM php:7.2-fpm-alpine

                    # Install packages
                    RUN docker-php-ext-configure pdo_mysql && docker-php-ext-install pdo_mysql
                    && apk add --update
                    ca-certificates
                    curl
                    git
                    zip
                    unzip
                    nano
                    && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
                    && rm -rf /var/cache/apk/*

                    # Configure php-fpm
                    COPY scripts/fpm-pool.conf /etc/php7/php-fpm.d/zzz_custom.conf
                    COPY scripts/php.ini /usr/local/etc/php/conf.d/zzz_custom.ini

                    # Add Application
                    WORKDIR /app
                    ADD . /app






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 30 '18 at 10:53









                    LatheesanLatheesan

                    12.5k1766130




                    12.5k1766130













                    • This looks like the same solution as I suggested in my answer, might I ask why you post it as your own answer instead of accepting the solution?

                      – Sven Hakvoort
                      Nov 30 '18 at 11:21











                    • Because I've shown how to properly do it for alpine & which command to use, i.e. docker-php-ext-configure pdo_mysql && docker-php-ext-install pdo_mysql .

                      – Latheesan
                      Nov 30 '18 at 11:39



















                    • This looks like the same solution as I suggested in my answer, might I ask why you post it as your own answer instead of accepting the solution?

                      – Sven Hakvoort
                      Nov 30 '18 at 11:21











                    • Because I've shown how to properly do it for alpine & which command to use, i.e. docker-php-ext-configure pdo_mysql && docker-php-ext-install pdo_mysql .

                      – Latheesan
                      Nov 30 '18 at 11:39

















                    This looks like the same solution as I suggested in my answer, might I ask why you post it as your own answer instead of accepting the solution?

                    – Sven Hakvoort
                    Nov 30 '18 at 11:21





                    This looks like the same solution as I suggested in my answer, might I ask why you post it as your own answer instead of accepting the solution?

                    – Sven Hakvoort
                    Nov 30 '18 at 11:21













                    Because I've shown how to properly do it for alpine & which command to use, i.e. docker-php-ext-configure pdo_mysql && docker-php-ext-install pdo_mysql .

                    – Latheesan
                    Nov 30 '18 at 11:39





                    Because I've shown how to properly do it for alpine & which command to use, i.e. docker-php-ext-configure pdo_mysql && docker-php-ext-install pdo_mysql .

                    – Latheesan
                    Nov 30 '18 at 11:39


















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53526168%2fcould-not-find-driver-error-in-lumen-5-6-app-running-in-docker-alpine-linux%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Lallio

                    Futebolista

                    Jornalista