I want to use localhost when used in php to point to the ip of the mysql container instead of pointing to itself so I can use the mysql container for data.
How can use localhost in my php call to mysql
$mysqli = new mysqli("localhost", "root", "examplepass", "set", 3306);
the above code won't work unless I use db as the hostname.
db:
image: mariadb
container_name: mariadb
environment:
MYSQL_ROOT_PASSWORD: examplepass
www:
build: ./images/www
links:
- db:mysql
ports:
- 8080:80
Do I have to change the hosts file in the container somehow through the Dockerfile or compose yaml?