0

I have only the Docker image file. I don't have docker-compose.yml file. I want to test it my local database with the Docker image. I tried to run the docker image with localhost database. But not able to connect my xampp Mysql

docker run -d -t -i -e MYSQL_DATABASE='database' -e MYSQL_HOSTNAME='localhost' -e MYSQL_PORT='3306' -e MYSQL_USER='root' -e MYSQL_PASSWORD='example' -p 8081:80 <DOCKERIMGID>

I tried 192.168.0.1 & 127.0.0.1, localhost, host.docker.internal

But, it's not working.

Thirsty Six
  • 399
  • 1
  • 6
  • 13

1 Answers1

0

At a first glance. MYSQL_HOSTNAME should be "host.docker.internal" instead of "mysql".

You may also need to grant access to the database to 'root'@'%'.