In my container when I run php artisan migrate I keep getting this error
In Connector.php line 67:
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
In Connector.php line 67:
PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known
Here's my .ENV file
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:etukbJpSLgbRsdf5uOEGtLT5Qw+XB6y06Q38HPr
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://127.0.0.1:8000/
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=project
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
I tried to change DB_HOST to mysql but still same result as well as changed it to mariadb
Here's my docker-compose file
version: '3'
services:
# The Application
app:
build:
context: ./
dockerfile: app.dockerfile
working_dir: /var/www
volumes:
- ../.:/var/www
- ./custom.ini:/usr/local/etc/php/conf.d/custom.ini
environment:
- "DB_PORT=3306"
- "DB_HOST=database"
# The Web Server
web:
build:
context: ./
dockerfile: web.dockerfile
working_dir: /var/www
volumes:
- ../.:/var/www
- ./vhost.conf:/etc/nginx/conf.d/default.conf
ports:
- 8082:80
# The Database
database:
image: mysql:5.7
volumes:
- dbdata:/var/lib/mysql
environment:
MYSQL_USER: ${DB_USERNAME}
MYSQL_DATABASE: ${DB_DATABASE}
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
ports:
- "33061:3306"
volumes:
dbdata:
I searched for solution online but none of them helped. Does anyone have a suggestion as to why I keep getting that error?
DB_HOST=localhost
when using a seperate container? – Nico Haase