I'm in trouble with my laradock project: i have downloaded and installed docker and i have successfully completed the setup of my laravel project with laradock. I use php 7, laravel(5.5.14) and the latest version of laradock. I start my project writing in shell:
docker-compose up -d nginx mysql
and all services starts. My env file is:
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=root
DB_PASSWORD=root
But when i try to use the migration with
php artisan migrate
i receive this error:
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known (SQL: select * from information_schema.tables where table_schema = homestead and table_name = migrations)
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known
PDO::__construct(): php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known
My db called homestead is created and it works. In my laravel project, under the migration folder i have 3 files php: create_user_table, create_password_reset_table and create_customer_table( i have wrote this file). I need to create a table in my db called customer with some colums:
Schema::create('customers', function (Blueprint $table) {
$table->increments('id');
$table->string('first_name');
$table->string('last_name');
$table->boolean('azienda');
$table->string('iva');
$table->string('ds');
$table->boolean('fatres');
$table->string('cf');
$table->string('mail');
$table->string('telefono');
$table->integer('sponsor');
$table->string('indinst');
$table->string('civinst');
$table->string('cityInst');
$table->string('capinst');
$table->string('provinst');
$table->string('indf');
$table->string('civf');
$table->string('capf');
$table->string('provf');
$table->string('cityFatt');
$table->timestamps();
});
How can i complete the migration and create the table? Thank you for answer!
@Stefano Zaniboni answered this in a comment but to expand:
I ran across this issue because I'm used to running php artisan
commands in my local directory rather than in a virtualbox / vagrant box / docker container.
The Laravel Docs mention that you need to run the php artisan migrate
command from within your virtual machine.
If you're using docker, you can get your container id using docker ps
. Then to ssh into the container use docker exec -it <containerId> /bin/bash
. Then just cd
into your project directory and run php artisan migrate
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With