Docker Community Forums

Share and learn in the Docker community.

Why I can run "php artisan migrate" from Ubuntu host and not from Windows

docker

(Pedrog) #1

Hello to everybody!

I have installed docker in Ubuntu 16.04 and Windows 10 pro. I use docker-compose and Laravel framework, the weird thing is that I can run “php artisan migrate” in Ubuntu without problems with the same docker-compose.yml, but in Windows return message “not found driver pdo”. I do all this from host, not container. Into container I have not got trouble.

I wonder why happens this issue, may be some body could help me.

I paste the yml file

Thanks

docker-compose.yml
version: '2’
services:

The Application

app:
build:
context: ./
dockerfile: app.dockerfile
working_dir: /var/www

volumes:
  - ./:/var/www
environment:
  - "DB_PORT=3306"
  - "DB_HOST=database"

The Web Server

web:
build:
context: ./
dockerfile: web.dockerfile
working_dir: /var/www
volumes_from:
- app
ports:
- 8080:80

The Database

database:
image: mysql:5.7
volumes:
- dbdata:/var/lib/mysql
restart: always
environment:
- “MYSQL_ROOT_PASSWORD=secret”
- “MYSQL_DATABASE=motordb”
- “MYSQL_USER=pedro”
- "MYSQL_PASSWORD=secret"
ports:
- “33061:3306”

The PhpMyadmin

phpmyadmin:
image: phpmyadmin/phpmyadmin
links:
- database:mysql
ports:
- 8181:80
environment:
PMA_USER: root
PMA_PASSWORD: secret
PMA_HOST: mysql

volumes:
dbdata:

Laravel environment file ".env"
APP_NAME=Motor
APP_ENV=local
APP_KEY=base64:0S0uQqTfYj02dsednm0S5iAPyNuF8uxWF50nX4opUKI=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=33061
DB_DATABASE=motordb
DB_USERNAME=pedro
DB_PASSWORD=secret

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=


(Pedrog) #2

Here is the proof from Ubuntu 16.04:

pedrog@pedrog-GA-MA74GM-S2:~/www/webmotor$ php artisan migrate
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_000000_create_users_table
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated: 2014_10_12_100000_create_password_resets_table
Migrating: 2017_08_22_170648_create_categories_table
Migrated: 2017_08_22_170648_create_categories_table
Migrating: 2017_08_22_170943_create_cars_table
Migrated: 2017_08_22_170943_create_cars_table
Migrating: 2017_08_22_170944_create_images_table
Migrated: 2017_08_22_170944_create_images_table
Migrating: 2017_08_23_012821_add_avatar_to_users_table
Migrated: 2017_08_23_012821_add_avatar_to_users_table
Migrating: 2017_08_23_013326_add_username_to_table
Migrated: 2017_08_23_013326_add_username_to_table


(Sam) #3

see https://laracasts.com/discuss/channels/laravel/php-artisan-migrate-windows-pdo-exception-could-not-find-driver

i don’t understand why this is a docker issue if you are issuing the command on windows host commandline


(Pedrog) #4

Yeah! it is weird, If I use “mysql -u pedro -p host=127.0.0.1port=33061” I can connect fine, then this is the same that var env into .env file? I guest yes… odd, odd, odd :wink:


(Pedrog) #5

May be that happens because I using Windwos 10 Pro Insider… I will try to change the Windows build to check that issue.


(Pedrog) #6

Eureka!! I had a PHP in my localhost, but the php.ini must match with php running in container.


(Sam) #7

Cool. Glad u found it.