Wcan
Wcan

Reputation: 878

Devilbox - How to connect laravel in docker with MySQL on host OS

I'm trying to connect the laravel app inside docker with MySQL on my host machine.

On my host machine MySQL is running is connected with following credentials.

Host OS MySQL

MySQL version: 8.0.27

Host: 127.0.0.1

Port: 3307

Password: No password

Devilbox .env file:

HOST_PORT_MYSQL=3306

Laravel .env file

DB_CONNECTION=mysql

DB_HOST=127.0.0.1

DB_PORT=3306

DB_DATABASE=hanger

DB_USERNAME=root

DB_PASSWORD=

OS / ENVIRONMENT:

Host operating system and version: MacOS Monterey 12.5.1

Docker desktop version: 4.12.0 (85629)

Docker desktop engine: Engine: 20.10.17

Docker desktop compose version: v2.10.2

If i run docker-compose up -d php httpd mysql everything work fine i'm able to connect to database via devilbox phpmyadmin.

As per the documentation https://devilbox.readthedocs.io/en/latest/corporate-usage/use-external-databases.html#database-on-host-os i ran this command docker-compose up -d php httpd bind but i unable to connect to the database from inside the docker to host OS MySQL.

I want to connect the laravel app in docker with MySQL on my host machine.

Upvotes: 0

Views: 680

Answers (0)

Related Questions