I have setup my first Docker containers to be able to have mysql8.o aside of the servers 5.7. version. I used Portainer to create a stack file. I’m on Debian12 server. Than tried to access phpmyadmin using the url . And it is throwing this error:
mysqli::real_connect(): php_network_getaddresses: getaddrinfo for db failed: Name or service not known
mysqli::real_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo for db failed: Name or service not known
I’m not sure what is wrong in my yaml for the containers? Tried several solutions I came across online. Not succeeded getting it to work.
It’s also mentioning: Control host, username and password in config.inc.php
Good idea, but where to find that file? If I search for it through the CLi, I can only find the config.php for the non-container-one. So how to look into the Docker Container en locate that file there?
Looks like adding 127. helped to locate the db? But the last error still remains. mysqli::real_connect(): (HY000/2002): Connection refused
So is it only a matter of wrong credentials?
Further this is my stack right now. What Am I missing to get it working?
services:
db:
image: mysql:latest
restart: always
container_name: mysqlV8
hostname: db
environment:
MYSQL_ROOT_PASSWORD: my-root-pass-word-here
MYSQL_DATABASE: webserver1
MYSQL_USER: container_data1
MYSQL_PASSWORD: my-dbase-pass-word-here
MYSQL_TCP_PORT: 3310
volumes:
- ./mysql_data:/var/lib/mysql
ports:
- "3310:3310"
phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
restart: always
container_name: phpmyadmin8
depends_on:
- db
environment:
PMA_HOST: 127.0.0.1:db
PMA_PORT: 3310
MYSQL_ROOT_PASSWORD: my-root-pass-word-here
PMA_USER: container_data1
PMA_PASSWORD: my-db-pass-word-here
ports:
- "8080:80"


