I’ve just started using Docker and Docker composer and I’m trying to set up a localhost development system. Currently, I’m using Phpstorm 2024 and Vs Code.
My problem is: I’m trying to build the stack “php:8.4.2-apache (which works) and mariadb and phpmyadmin (which I get connection errors)”
When I log into phpmyadmin I get this message
"Welcome to phpMyAdmin
Error
MySQL Message: Documentation
Cannot connect: invalid settings.
mysqli::real_connect(): (HY000/1045): Access denied for user ‘user’@‘172.18.0.4’ (using password: YES)
phpMyAdmin tried to connect to the MySQL server and the connection was refused. You should check the server, username and password in config.inc.php and make sure they match the information provided by the MySQL server administrator."
MY docker composer
version: "3.8"
services:
php:
image: php:8.4-apache # Considere atualizar para uma versão mais recente
container_name: php
volumes:
- ./src:/var/www/html
- ./php.ini:/usr/local/etc/php/php.ini
ports:
- "8080:80"
networks:
- backend
depends_on:
- mariadb
mariadb:
image: mariadb:latest
container_name: mariadb
restart: always
environment:
MARIADB_ROOT_PASSWORD: 123456
MARIADB_DATABASE: default_database
MARIADB_USER: user
MARIADB_PASSWORD: user
volumes:
- mariadb_data:/var/lib/mysql
networks:
- backend
phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
container_name: phpmyadmin
restart: always
environment:
PMA_HOST: mariadb # Usa o nome do serviço para resolução interna
PMA_USER: user
PMA_PASSWORD: user
ports:
- "8181:80"
networks:
- backend
depends_on:
- mariadb
volumes:
mariadb_data:
networks:
backend: