How to setup local laravel with containered mysql service

Viewed 44

i know there are tons of answer for question like these, but i still not able to connect. I have a local clean installation of laravel 8 and a docker container running mysql. I am able to access the container and manage it, but when run migrate got "SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known". Some advice will be nice, thx.

My .env:

DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=birdboard
DB_USERNAME=pedro
DB_PASSWORD=123456

my docker-compose.yml

version: "3.5"

services:
  mysql:
    build: phpdocker/mysql57
    container_name: mysql
    ports:
      - "3306:3306"
    expose:
      # Opens port 3306 on the container
      - "3306"
      # Where our data will be persisted
    volumes:
      - mysql:/var/lib/mysql

# Names our volume
volumes:
  mysql:
1 Answers

maybe your .env file is wrong

DB_CONNECTION=mysql
DB_HOST=127.0.0.1 
DB_PORT=3306 
DB_DATABASE=birdboard 
DB_USERNAME=pedro 
DB_PASSWORD=123456
Related